#!/bin/bash # -e Exit immediately if a command exits with a non-zero status. # -u Treat unset variables as an error when substituting. set -eu START=`date +%s` PROJECT=lowtechweb echo echo "┌┐░░░░░░┌──┐░░┌┐░┌┬─┬┐░┌┐░" 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 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 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 docker build . -t kosssi/$PROJECT docker tag kosssi/$PROJECT registry.weko.io/$PROJECT docker push registry.weko.io/$PROJECT elif [ $1 == "deploy" ]; then echo "🚀 Déploiement avec docker-compose" echo docker-compose up -d elif [ $1 == "install" ]; then install fi else help fi END=`date +%s` echo "✨ Done in $((END-START))s"