Jekyll Auto-Build With Git Hooks· 1 minute, 41 seconds
tl;dr: Use the full path to your
jekyll executable when running it from a git hook.
As much as I love Jekyll for it's nerdiness and it's speed, as much can it be annoying at times when you have to "compile" your website and upload it to your server every time you fix a comma. This situation lends itself to get automated.
First things first: I host my website on Uberspace. I mentioned before that they're just the best, right1? Anyway, at Uberspace, they don't have Jekyll pre-installed so you have to install it yourself. And since you can't just install it for the entire machine, you have to install it on a per-user basis:
gem install --user jekyll
This allows you to still run
jekyll from the terminal as you normally would. However, this doesn't seem to apply when working executing a
post-receive git hook included in your server repository.
GIT_REPO=$HOME/git/flohei.de.git TMP_GIT_CLONE=$HOME/tmp/myrepo PUBLIC_WWW=$HOME/html git clone $GIT_REPO $TMP_GIT_CLONE cd $TMP_GIT_CLONE ~/.gem/ruby/1.9.1/bin/jekyll build -s $TMP_GIT_CLONE -d $PUBLIC_WWW rm -Rf $TMP_GIT_CLONE exit
I assume that this applies to any setup where you're not able to install software on a machine-level but only on your user account. So feel free to drop me a line if this helped you, even with another setup.
If you can see this post, this means that this system is working as intended.