Deploying blog with GitLab

March 9, 2014

Although I keep my blog on GitHub I also have another copy in my gitlab instance. To deploy the blog I use the post-receive hook of my repository in gitlab.

Why I do this? There are a few things that bug me when using GitHub-Pages. Biggist being that it’s not very clear when compilation is done and the new version is up and running. Now, if I didn’t have my server running in 98% idle most of the time gh-pages would probably suffice.

My post-receive script:



echo Deploy Le Blog
rm -Rf $PUBLIC_WWW/*
echo "Clone Git Repo"
git clone $GIT_REPO $TMP_GIT_CLONE > /dev/null
echo Build Jekyll Site
jekyll build -s $TMP_GIT_CLONE -d $PUBLIC_WWW
echo Cleanup

My nginx vhost:

server {
  listen   80;


  root /var/www/;
  index index.html;

  error_page 404 /404.html;

  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
    root /usr/share/nginx/www;

Of course these scripts only work when the gitlab instance and the webserver are both running on the same machine.

Even though I like this setup I will be playing around with WebHooks and see if I find a solution I like better. Anyway I will post my results.