55 lines
1.6 KiB
Bash
Executable File
55 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
if [ -f "$SCRIPT_DIR/.env" ]; then
|
|
# Export all variables from .env for the duration of the script
|
|
set -a
|
|
. "$SCRIPT_DIR/.env"
|
|
set +a
|
|
fi
|
|
|
|
# Configuration
|
|
DEST_USER="${DEPLOY_DEST_USER:?DEPLOY_DEST_USER manquant}"
|
|
DEST_HOST="${DEPLOY_DEST_HOST:?DEPLOY_DEST_HOST manquant}"
|
|
DEST_DIR="/var/lib/www/richard-dern.fr/"
|
|
HUGO_ENV="production"
|
|
TARGET_OWNER="caddy:caddy"
|
|
|
|
echo "==> Vérification des liens externes"
|
|
node "$SCRIPT_DIR/tools/check_external_links.js"
|
|
|
|
echo "==> Vérification des liens internes"
|
|
node "$SCRIPT_DIR/tools/check_internal_links.js"
|
|
|
|
echo "==> Enrichissement météo des articles"
|
|
node "$SCRIPT_DIR/tools/add_weather.js"
|
|
|
|
echo "==> Génération des statistiques"
|
|
npm run stats:generate
|
|
|
|
# echo "==> Application des taxonomies et mots-clés"
|
|
# node "$SCRIPT_DIR/tools/link_taxonomy_terms.js"
|
|
|
|
# echo "==> Ajout des liens vers les mots-clés du frontmatter"
|
|
# node "$SCRIPT_DIR/tools/link_frontmatter_keywords.js"
|
|
|
|
echo "==> Génération du site Hugo pour l'environnement $HUGO_ENV (avec nettoyage de destination)"
|
|
hugo --environment "$HUGO_ENV" --cleanDestinationDir
|
|
|
|
echo "==> Synchronisation du site vers le serveur $DEST_HOST"
|
|
rsync -avz --delete \
|
|
--exclude='data/***' \
|
|
--no-owner --no-group \
|
|
--checksum \
|
|
public/ "$DEST_USER@$DEST_HOST:$DEST_DIR"
|
|
|
|
CMD="find \"$DEST_DIR\" -type d -name data -exec rm -rf {} +"
|
|
ssh "$DEST_USER@$DEST_HOST" "$CMD"
|
|
|
|
echo "==> Correction des droits sur le serveur"
|
|
ssh "$DEST_USER@$DEST_HOST" "chown -R $TARGET_OWNER '$DEST_DIR'"
|
|
|
|
echo "==> Déploiement terminé avec succès."
|