diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-19 19:42:42 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-19 19:42:42 +0800 |
| commit | 9d71d06a1f3ee294634bf45373bbf1944bf03caf (patch) | |
| tree | e2f11ba0461615d51ea9e5469d0fd0038ba0e971 /deploy/git-hook/post-receive | |
| parent | ead9932988f519932af39767ae09cf55081bd17f (diff) | |
| download | blog-9d71d06a1f3ee294634bf45373bbf1944bf03caf.tar.gz | |
chore: add self-hosted deploy pipeline (blog-deploy)
Diffstat (limited to 'deploy/git-hook/post-receive')
| -rwxr-xr-x | deploy/git-hook/post-receive | 21 |
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 |
