furtka/website/deploy-ci.sh
Daniel Maksymilian Syrnicki 22ce03d1f0
Some checks failed
CI / lint (push) Failing after 31s
CI / validate-json (push) Successful in 22s
CI / test (push) Successful in 1m23s
Deploy site / deploy (push) Successful in 5s
CI / markdown-links (push) Successful in 14s
fix(website): build on Hugo 0.147 again (site.Data), chown site trees even when the CI build fails
hugo.Data is not available in the alpine Hugo the deploy job uses; the
failed render left the webroot half-cleaned and root-owned because the
chown only ran after a successful build. It is an EXIT trap now.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MScAinbyMdeNc7H2BZdnnG
2026-08-26 13:35:40 +02:00

34 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Auto-deploy path run by .forgejo/workflows/deploy-site.yml inside the
# self-hosted runner — which is forge-runner-01, the actual web server.
# Same effect as deploy.sh but without the SSH hop: everything is local.
#
# Requires `rsync` and `hugo` on PATH. The workflow apk-installs both
# before invoking this script.
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
SRCROOT="${FURTKA_SRCROOT:-/srv/furtka-site}"
WEBROOT="${FURTKA_WEBROOT:-/var/www/furtka.org}"
# The runner job runs as root inside the container; hand the trees back
# to the VM user no matter how this script ends, so the manual deploy.sh
# path keeps working even after a failed build.
if [ "$(id -u)" = 0 ]; then
trap 'chown -R "${FURTKA_OWNER:-1000:1000}" "$SRCROOT" "$WEBROOT"' EXIT
fi
echo "==> rsync website/ → $SRCROOT"
rsync -az --delete \
--exclude='.hugo_build.lock' \
--exclude='public/' \
--exclude='resources/' \
--exclude='deploy.sh' \
--exclude='deploy-ci.sh' \
"$HERE/" "$SRCROOT/"
echo "==> hugo build → $WEBROOT"
cd "$SRCROOT"
hugo --minify --cleanDestinationDir -d "$WEBROOT"
echo "OK: deployed to https://furtka.org/"