Note: this works for us on a Ubuntu server.
The first step was to install Jekyll and Ruby on a server where the blog was to be hosted. I skip bits about setting up a domain name and hosting, and ….
We have a separate account for gitolite with very limited access rights. This means that we had to install Ruby and Jekyll under a different account. As a result, there was quite a bit of experimenting involved but we got there.
In no way this is the best possible approach, but it works for now and we may improve it as necessary.
The main integration point is a
post-receive hook of git. The complete content of our version is below but first you will need a couple of configuration variables. The best way to get them is to run
env (sorry guys, we live in a Linux world) when logged in as the user used for installing Jekyll and Ruby. You need the following variables:
The git repo and the blog are on the same server, so we could simply use a file/folder reference for the destination web server. Remote deployments would need rsync, scp, or something similar.
You can see that the script has two if statements - for
develop branches. The develop deploys files to a domain name with internal access only. This allows for a bit of experimenting or proof-reading before a new post is published.
Note: I also added the “git/gitolite” user to the group of the Ruby-installation-user but it may not be necessary.
Note: to show drafts in the test web site, change the “jekyll build” command in the “develop” branch to: