89 lines
2.6 KiB
Bash
Executable File
89 lines
2.6 KiB
Bash
Executable File
#!/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
|
|
|
|
DOCKER_CONTEXT=vert
|
|
START=`date +%s`
|
|
|
|
help() {
|
|
echo
|
|
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 prod 🚀 Déploiement du site en mode production"
|
|
echo "- ./run staging 🚀 Déploiement du site en mode staging"
|
|
echo "- ./run favicon 🎨 Création du favicon"
|
|
echo
|
|
}
|
|
|
|
favicon() {
|
|
# https://stackoverflow.com/questions/39256104/how-to-convert-an-image-file-from-svg-to-a-multi-size-ico-without-blur-sharp
|
|
convert -density 300 -define icon:auto-resize=48,32,16 -background none static/icons/blason-512x512.png static/favicon.ico
|
|
}
|
|
|
|
prod() {
|
|
echo
|
|
echo "🚀 Déploiement du site en mode production 🚀"
|
|
echo
|
|
rm -rf public
|
|
hugo --minify --environment production
|
|
node themes/hugo-theme-lowtech/scripts/typo
|
|
#DATE=`date +\"%Y0101\"` && find public -exec touch -d $DATE {} +
|
|
docker-compose --context $DOCKER_CONTEXT -f docker-compose.prod.yml up -d --build --force-recreate
|
|
}
|
|
|
|
staging() {
|
|
echo
|
|
echo "🚀 Déploiement du site en mode staging 🚀"
|
|
echo
|
|
rm -rf public
|
|
hugo --minify --environment staging
|
|
node themes/hugo-theme-lowtech/scripts/typo
|
|
cp themes/hugo-theme-lowtech/robots.txt public
|
|
#DATE=`date +\"%Y0101\"` && find public -exec touch -d $DATE {} +
|
|
docker-compose --context $DOCKER_CONTEXT -f docker-compose.staging.yml up -d --build --force-recreate
|
|
}
|
|
|
|
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 == "prod" ]; then
|
|
prod
|
|
elif [ $1 == "staging" ]; then
|
|
staging
|
|
elif [ $1 == "install" ]; then
|
|
install
|
|
elif [ $1 == "favicon" ]; then
|
|
favicon
|
|
fi
|
|
else
|
|
help
|
|
fi
|
|
|
|
END=`date +%s`
|
|
echo
|
|
echo "✨ Done in $((END-START))s"
|
|
echo
|