First try
This commit is contained in:
25
hooks/update_site.sh
Normal file
25
hooks/update_site.sh
Normal 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
|
Reference in New Issue
Block a user