#!/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 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!"