2026-09-08
I've just got a git hook working, so that my website updates itself after a push to main.
To do this, you need a script in your remote repository called `hooks/post-update`. Given that I'm hosting my gemini:// capsule on the same machine, but the https:// website on another one on the same network, my script looks a little like this:
#!/bin/sh
log=~nginx/logs/joeac.net.git-post-update.log
echo "pushing changes to https://joeac.net and gemini://joeac.net"
(
ssh <user>@<http_machine> 'git -C <dir> pull; make -C <dir>/gemini'
git -C <dir> pull
make -C <dir>/gemini
) 2>> $log 1>&2 &
A few tricks:
- don't forget to `chmod +x` the script
- the user that will run this hook script is the same as the user that hosts your git repository: in my case, that's the user `nginx`
- make sure `nginx` has a public key stored in the remote user's `~/.ssh/authorized_keys` file
- any output to stdout or stderr goes back to the git-pusher's CLI
- I've used a sub-shell and redirects to put logs in a logfile and not return them to the git-pusher
- I've also used the ampersand `&` operator so the git-pusher isn't hanging around waiting for the build to finish