#!/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 .git repository for the first time" git clone $HUGO_GIT_URL $HUGO_WORKING_DIR else echo "All good!" fi cd $HUGO_WORKING_DIR echo "◆ Pull latest version from .git repository" # Force pull everything, just in case git fetch --all git reset --hard origin/main echo "◆ Build static HTML page with hugo" # Start building website with hugo hugo # Clean the public folder without affecting what's currently served by HTTP # server 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!"