#!/bin/sh REPO=/users/home/andrewlkho/git/design/andrewho.co.uk.git PUBLIC=/users/home/andrewlkho/web/public GEM_HOME=/users/home/andrewlkho/local/gems GEM_PATH=/users/home/andrewlkho/local/gems:/usr/local/lib/ruby/gems/1.8 RUBYLIB="/users/home/andrewlkho/local/lib:${RUBYLIB}" PATH="/users/home/andrewlkho/local/bin:/users/home/andrewlkho/local/gems/bin:${PATH}" # It took a while to discover this non-intuitive requirement export GEM_HOME GEM_PATH RUBYLIB while read OLDREV NEWREV REFNAME; do if [ ${REFNAME} = "refs/heads/master" ]; then MASTER_UPDATED=1 fi done if [ ${MASTER_UPDATED} ]; then # Setup a temporary staging directory COMMITID=`cat ${REPO}/refs/heads/master` TMP=/users/home/andrewlkho/tmp STAGING="${TMP}/${COMMITID}" mkdir -p ${STAGING} # Grab a copy of master's HEAD git archive --format=tar refs/heads/master | gtar -C ${STAGING} -x -f - # Generate the site with jekyll cd ${STAGING} jekyll > /dev/null # Copy it over to the public directory rsync -aqz --delete ${STAGING}/_site/ ${PUBLIC} # Clean up cd rm -rf ${STAGING} fi