Profile cover photo
Profile photo
… read code … see patterns … evolve
… read code … see patterns … evolve

Toke's posts

Post has attachment
Or how this site is updated

This site is build via jekyll and the sources are coming from a git repository on github. I do not write something special about git or jekyll here. Just how the “deployment” works.

Github webhook

Github has a nice feature called “Service hooks” - especially a “Post-Receive URLs” hook. I use this hook to notify my server to do a “git pull” on a local repository, then rebuild the site with jekyll and rsync changed data to the document root.

The webhook endpoint ( code):

package ReceiveHook;
use Dancer ':syntax';

our $VERSION = '0.3';

# Configuration for different projects
my $config = {
run => "/home/user/bin/",

prefix '/notify';

get '/*' => sub {
header 'Allow' => 'POST';
status '405';
"Not for you\n";

post '/:project' => sub {
if (not defined $config->{params->{project}}) {
status 'not_found';
return "No such project: ".params->{project}."\n";

my $payload = params->{'payload'};
if (not defined $payload) {
status '415';
return "I need a payload\n";

# Read the configuration for that repo
my $repo_config = $config->{$repo->{name}};
if (defined $repo_config && defined $repo_config->{run}) {
eval {
system $repo_config->{run};

return "OK";


The update itself is done by this little shellscript:



if [ -d ${REPPATH} ] ; then
cd "${REPPATH}"
git pull
jekyll --url "${LIVEURL}"
rsync -rXogpEAt _site/ "${DEPLOYTARGET}"


That is just the surface what really is possible. I also use this method in different other setups. Just to mention differnet usecases:

Keep repositories synchronized
Automatic Builds
Automatic deployments
Test framework
Configuration management
Even a small distributed site or WiKi is possible
With a simple git post-commit-hook such a http Post with curl it is github independent.

To be continued…

Post has attachment
Wait while more posts are being loaded