From d101ca8d0f4e5eaa814afa8592522b4b7ef08c34 Mon Sep 17 00:00:00 2001 From: Simon C Date: Mon, 11 May 2020 18:03:50 +0200 Subject: [PATCH] mix ... --- .drone.yml | 2 +- config.yml => config/_default/config.yml | 0 config/development/config.yml | 1 + config/production/config.yml | 1 + config/staging/config.yml | 1 + run | 80 +++++++++++++++++++----- 6 files changed, 67 insertions(+), 18 deletions(-) rename config.yml => config/_default/config.yml (100%) create mode 100644 config/development/config.yml create mode 100644 config/production/config.yml create mode 100644 config/staging/config.yml diff --git a/.drone.yml b/.drone.yml index 0063696..b20edcd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -30,7 +30,7 @@ steps: image: registry.lamelio.fr/hugo commands: - ./run install - - ./run build + - ./run build staging when: branch: - master diff --git a/config.yml b/config/_default/config.yml similarity index 100% rename from config.yml rename to config/_default/config.yml diff --git a/config/development/config.yml b/config/development/config.yml new file mode 100644 index 0000000..f73c4a5 --- /dev/null +++ b/config/development/config.yml @@ -0,0 +1 @@ +baseURL: http://127.0.0.1:1313/ diff --git a/config/production/config.yml b/config/production/config.yml new file mode 100644 index 0000000..4b07c6a --- /dev/null +++ b/config/production/config.yml @@ -0,0 +1 @@ +baseURL: https://lowtechweb.com/ diff --git a/config/staging/config.yml b/config/staging/config.yml new file mode 100644 index 0000000..9a5f265 --- /dev/null +++ b/config/staging/config.yml @@ -0,0 +1 @@ +baseURL: https://staging.lowtechweb.com/ diff --git a/run b/run index 4936ff0..fab3209 100755 --- a/run +++ b/run @@ -13,35 +13,81 @@ echo "││┌─┬┬┬┐└┐┌┴┬─┤└┐││││├─┤ echo "│└┤┼││││░││┴┤─┤│││││││┴┤┼│" echo "└─┴─┴──┘░└┴─┴─┴┴┘└─┴─┴─┴─┘" echo +echo + +build_production() { + echo "👷 Construction du site en mode production" + rm -rf public + hugo --environment production --minify + node themes/hugo-theme-lowtech/scripts/typo +} + +build_staging() { + echo "👷 Construction du site en mode staging" + rm -rf public + hugo --environment staging -D --minify + node themes/hugo-theme-lowtech/scripts/typo +} + +help() { + echo "💡 Aide" + echo "-------" + echo + echo "Commandes :" + echo "- ./run install 📦 Installation des dépendances" + echo "- ./run dev 🚧 Lancement du serveur pour le développement" + echo "- ./run dev production 🚧 Lancement du serveur pour le développement sans les brouillons" + echo "- ./run build production 👷 Construction du site en mode production" + echo "- ./run build staging 👷 Construction du site en mode staging" + echo "- ./run docker 🐳 Création de l'image Docker" + echo "- ./run deploy 🚀 Déploiement avec docker-compose" + echo +} + +install() { + echo "📦 Installation des dépendances" + echo "-------------------------------" + echo + echo "- Récupération du theme" + git submodule update --init + echo "- Installation des dépendances node du theme" + cd themes/hugo-theme-lowtech && npm i +} if [ $# -ge 1 ]; then if [ $1 == "dev" ]; then - hugo server -D + if [ $# -ge 2 ] && [ $2 == "production" ]; then + echo "🚧 Lancement du serveur pour le développement sans les brouillons" + hugo server + else + echo "🚧 Lancement du serveur pour le développement" + hugo server -D + fi elif [ $1 == "build" ]; then - rm -rf public - hugo -D --minify - node themes/hugo-theme-lowtech/scripts/typo - elif [ $1 == "deploy" ]; then - echo "😎 Commence le déploiement du site" + if [ $# -ge 2 ] && [ $2 == "staging" ]; then + build_staging + elif [ $# -ge 2 ] && [ $2 == "production" ]; then + build_production + else + echo "💥 Il faut choisir l'environnement (production ou staging)" + echo + help + fi + elif [ $1 == "docker" ]; then + echo "🐳 Création de l'image Docker" echo - echo "- Construction de l'image docker 🚀" docker build . -t kosssi/$PROJECT docker tag kosssi/$PROJECT registry.lamelio.fr/$PROJECT docker push registry.lamelio.fr/$PROJECT + elif [ $1 == "deploy" ]; then + echo "🚀 Déploiement avec docker-compose" + echo docker-compose up -d elif [ $1 == "install" ]; then - echo "- Initialisation de git submodule" - git submodule update --init - echo "- Installe les dépendances node" - cd themes/hugo-theme-lowtech && npm i + install fi else - echo "Commands:" - echo "- ./run install : Installe les dépendances" - echo "- ./run dev : Lance hugo pour le développement avec l'autoreload" - echo "- ./run build : Lance la génération du site pour la prod" - echo "- ./run deploy : Lance le déploiement du site" - echo + help fi END=`date +%s`