lloydsla.de random hacks and pointless shenanigans

Deploying Jekyll sites with GitLab

This site1 uses Jekyll to generate static pages, which I manage using GitLab. I was using a hacked-together local Git hook to regenerate the site and copy the files to my webserver’s root directory after each commit, but I wanted a solution that both worked no matter where I was commiting and pushing changes from and didn’t involve PHP.2

The obvious solution is a Web hook. I found a couple of PHP scripts that probably would have worked, but I really wasn’t in the mood to klutz around with my kinda-working PHP configuration. I then found git-fish, a Node.js web hook listener. Luckily, my quick-and-dirty bash script still works fine. Here’s a blank example you can use:3

#!bin/bash
cd /your/jekyll/working/directory
pwd
# If you're watching a logfile, using pwd is
# optional but handy for troubleshooting

jekyll build
cp -r /your/jekyll/working/directory/_site/* /web/root/directory

Once you’ve done this, configure git-fish to listen on a certain port (and make sure that port’s open on the firewall), have it call the script when it recieves an event, and you should be done!

  1. ...which, so far, is 100% self-documentation
  2. I don't like PHP much. More importantly, I wasn't in the mood to fight with my semi-broken but also generally-working nginx/php-fpm setup, since that might break it harder.
  3. Helpful code critiques can be emailed to me. Unhelpful ones should be forwarded to /dev/null