From 947b7f234eef903cfeae7434fc256b2782558bdb Mon Sep 17 00:00:00 2001 From: Jonathan Dahan Date: Sat, 25 May 2024 21:08:18 -0400 Subject: [PATCH] self-updating post-receive. this is an awful idea --- hooks/post-receive | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/hooks/post-receive b/hooks/post-receive index 3becb96..5e88f0f 100755 --- a/hooks/post-receive +++ b/hooks/post-receive @@ -3,25 +3,28 @@ set -e -u -o pipefail while read oldrev newrev ref do - if [[ $ref =~ .*/main$ ]]; - then - echo "main ref received" + if [[ $ref =~ .*/main$ ]]; then + echo "main ref received" echo "moving into temporary work tree"; { - gitdir=$PWD - cd $(mktemp -d) - } + gitdir=$PWD + cd $(mktemp -d) + } - echo "checking out latest source"; { - git --work-tree=$PWD --git-dir=$gitdir checkout --force - } + echo "checking out latest source"; { + git --work-tree=$PWD --git-dir=$gitdir checkout --force + } - echo "generating static site"; { - podman-compose build - } + echo "generating static site"; { + podman-compose build + } - echo "restarting server"; { - podman-compose restart || podman compose up - } - fi + echo "restarting server"; { + podman-compose restart || podman compose up + } + + echo "updating post-receive hook for future runs"; { + cp hooks/post-receive $0 + } + fi done