Files
parasol-static-site/deploy.sh.tmpl
Amras 0e00a57192 Install node plugins during deploy
Hugo supports using NPM as part of its build process
 this is required for some features, e.g. tailwindcss:
 https://gohugo.io/functions/css/tailwindcss/#setup

This change checks if "package.json" exists.
If so, it installs node and runs npm install.
2026-11-06 23:13:39 +01:00

58 lines
1.2 KiB
Cheetah
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 [ ! -z "$HUGO_GIT_BRANCH" ]; then
echo "Checkout $HUGO_GIT_BRANCH"
git reset --hard origin/$HUGO_GIT_BRANCH
git checkout origin/$HUGO_GIT_BRANCH
fi
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 "◆ Install or update NPM Modules"
if [ -f "package.json" ]; then
apk add nodejs npm
npm install
fi
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!"