First try

This commit is contained in:
2025-10-07 22:41:25 +02:00
parent 6a4dbbd226
commit 3fec68a2a9
5 changed files with 149 additions and 0 deletions

25
hooks/update_site.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail
# This script is invoked by adnanh/webhook when a matching hook is triggered.
# It updates the git checkout in /app/site to origin/$GIT_BRANCH.
# Hugo server runs separately and watches the files, so no explicit hugo build is required.
REPO_DIR="/app/site"
GIT_BRANCH="${GIT_BRANCH:-main}"
if [ ! -d "$REPO_DIR/.git" ]; then
echo "Repository not found at $REPO_DIR; nothing to update."
exit 1
fi
echo "Updating repository in $REPO_DIR to origin/$GIT_BRANCH"
cd "$REPO_DIR"
# Fetch and reset
git fetch origin "$GIT_BRANCH" --depth=1 || true
git reset --hard "origin/$GIT_BRANCH"
# Optionally, you can clear caches or perform other tasks here.
echo "Update completed at $(date -u +%Y-%m-%dT%H:%M:%SZ)"
exit 0