summaryrefslogtreecommitdiff
path: root/deploy/git-hook/post-receive
diff options
context:
space:
mode:
Diffstat (limited to 'deploy/git-hook/post-receive')
-rwxr-xr-xdeploy/git-hook/post-receive21
1 files changed, 21 insertions, 0 deletions
diff --git a/deploy/git-hook/post-receive b/deploy/git-hook/post-receive
new file mode 100755
index 00000000..65cec98a
--- /dev/null
+++ b/deploy/git-hook/post-receive
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+# Runs INSIDE the gitweb container (uid 1000) on git-http-backend pushes.
+# Only writes a signal into the bare repo; the host systemd path unit
+# (/home/somhairle/git/blog.git/deploy.signal) picks it up and builds.
+set -u
+ZERO=0000000000000000000000000000000000000000
+GITDIR=$(git rev-parse --git-dir 2>/dev/null) || exit 0
+while read -r oldrev newrev refname; do
+ case "$refname" in
+ refs/heads/main)
+ if [ "$newrev" != "$ZERO" ]; then
+ if printf '%s %s\n' "$newrev" "$(date -u +%FT%TZ)" > "$GITDIR/deploy.signal" 2>/dev/null; then
+ echo "blog-deploy: build signal written for $newrev" >&2
+ else
+ echo "blog-deploy: WARNING could not write deploy.signal" >&2
+ fi
+ fi
+ ;;
+ esac
+done
+exit 0