Skip to content

Instantly share code, notes, and snippets.

@rocx
Last active August 19, 2017 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rocx/3f7572e0d03aca342d6d55b55f8eac36 to your computer and use it in GitHub Desktop.
Save rocx/3f7572e0d03aca342d6d55b55f8eac36 to your computer and use it in GitHub Desktop.
Git hook to publish a la Jekyll
#!/usr/bin/env sh
# post-receive - build the site after a push
# TODO: a pre-something hook to check if it would build.
# TODO: change this hook to checking if the produced markup is valid.
# more or less the hook from http://jekyllrb.com/docs/deployment-methods/
REPO=/var/www/repos/my-site.git
TEMP=`mktemp -dt site-XXXXXX`
SITE=/var/www/my-site
(cd ${REPO} && git archive HEAD) | TAPE=- tar -xC ${TEMP}
jekyll build -s ${TEMP} -d ${SITE}
rm -rf ${TEMP}
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment