lowtechweb/run

95 lines
2.8 KiB
Plaintext
Raw Permalink Normal View History

#!/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`
2020-05-08 10:26:57 +02:00
PROJECT=lowtechweb
echo
echo "┌┐░░░░░░┌──┐░░┌┐░┌┬─┬┐░┌┐░"
echo "││┌─┬┬┬┐└┐┌┴┬─┤└┐││││├─┤└┐"
echo "│└┤┼││││░││┴┤─┤│││││││┴┤┼│"
echo "└─┴─┴──┘░└┴─┴─┴┴┘└─┴─┴─┴─┘"
echo
2020-05-11 18:03:50 +02:00
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
2020-05-11 18:03:50 +02:00
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
2020-05-11 18:03:50 +02:00
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"
2020-05-08 10:26:57 +02:00
echo
docker build . -t kosssi/$PROJECT
docker tag kosssi/$PROJECT registry.weko.io/$PROJECT
docker push registry.weko.io/$PROJECT
2020-05-11 18:03:50 +02:00
elif [ $1 == "deploy" ]; then
echo "🚀 Déploiement avec docker-compose"
echo
2020-05-08 10:26:57 +02:00
docker-compose up -d
elif [ $1 == "install" ]; then
2020-05-11 18:03:50 +02:00
install
fi
else
2020-05-11 18:03:50 +02:00
help
fi
END=`date +%s`
echo "✨ Done in $((END-START))s"