self-updating post-receive. this is an awful idea

main
Jonathan Dahan 12 months ago
parent 4af558d4ce
commit 947b7f234e

@ -3,25 +3,28 @@ set -e -u -o pipefail
while read oldrev newrev ref while read oldrev newrev ref
do do
if [[ $ref =~ .*/main$ ]]; if [[ $ref =~ .*/main$ ]]; then
then echo "main ref received"
echo "main ref received"
echo "moving into temporary work tree"; { echo "moving into temporary work tree"; {
gitdir=$PWD gitdir=$PWD
cd $(mktemp -d) cd $(mktemp -d)
} }
echo "checking out latest source"; { echo "checking out latest source"; {
git --work-tree=$PWD --git-dir=$gitdir checkout --force git --work-tree=$PWD --git-dir=$gitdir checkout --force
} }
echo "generating static site"; { echo "generating static site"; {
podman-compose build podman-compose build
} }
echo "restarting server"; { echo "restarting server"; {
podman-compose restart || podman compose up podman-compose restart || podman compose up
} }
fi
echo "updating post-receive hook for future runs"; {
cp hooks/post-receive $0
}
fi
done done

Loading…
Cancel
Save