parasol-static-site/deploy.sh.tmpl

45 lines
929 B
Bash
Executable File

#!/bin/bash
set -e
echo "◆ Check .git repository"
if [ -z "$HUGO_GIT_URL" ]; then
echo "△ HUGO_GIT_URL environment variable is not set"
exit 1
fi
if [ ! -d "$HUGO_WORKING_DIR" ]; then
echo "Clone $HUGO_GIT_URL for the first time"
git clone $HUGO_GIT_URL $HUGO_WORKING_DIR
else
echo "$HUGO_GIT_URL is already cloned"
fi
cd $HUGO_WORKING_DIR
echo "◆ Pull latest version from .git repository"
git fetch --all
git reset --hard origin/main
if [ "$CUSTOM_DEPLOY_ENABLED" == "1" ]; then
echo "◆ Executing custom deploy script: $HUGO_WORKING_DIR/$CUSTOM_DEPLOY_SCRIPT"
bash $HUGO_WORKING_DIR/$CUSTOM_DEPLOY_SCRIPT
exit 0
fi
echo "◆ Install or update Hugo Modules"
hugo mod get -u
echo "◆ Build static HTML page with Hugo"
hugo --logLevel info
rm -rf $HUGO_PUBLIC_DIR/*
cp -r $HUGO_WORKING_DIR/public/* $HUGO_PUBLIC_DIR
rm -rf $HUGO_WORKING_DIR/public/*
echo "▷ Sucessfully built new website!"