Controlled Jekyll Republishing with git Commit Messages

Nov 2, 2015

Relevant XKCD

It’s only fitting to start this little scrapbook with a short snippet for Jekyll. I’m a typical engineer in that I am willing to spend five hours setting something up that will save me 20 seconds about every other month, so I was tempted by the git post-receive hook deployment method from the Jekyll documentation.

Such a complete automatism doesn’t fit my usual workflow, however. I often push unfinished/untested code, mostly for the benefit of a remote backup.And while Jekyll has drafts, that mechanism does not help with changes to the rest of the codebase.

What I wanted was a method to control which pushes lead to redeployments. I’ve settled on the following post-receive hook, which only redeploys if the last commit message contains the string 'p! ' (without quotes). This method is adaptable to perform any conditional post-push action based on commit messages or other information in the git log.

# Republish Jekyll when last commit message
# contains p!

LOG=`git log -1 --pretty=%B HEAD`

if [[ $LOG != *"p! "* ]]
echo "We're keeping this version private."

echo "Publishing... "


jekyll build -s $TMP_GIT_CLONE -d $PUBLIC_WWW
echo "Done. Time to die. How fitting for a damn shell script."


I have a deep hatred for bash scripting and therefore not invested much time. Consider:

Redeploys only happen when the last commit message contains 'p! '. Any intermediate commits that where not pushed are ignored.

The 'p! ' trigger can occure anywhere in the commit message, not just at the beginning.

A better method would be to use branches for intermediate code. But we’re publishing a blog here and avoiding work clearly outranks orthodoxy.

Other Articles

Mark Felt-Tipped Feb 25, 2018

Building Tensorflow 1.5.0 on MacOS with CUDA GPU Jan 21, 2018

Contact Jan 1, 2018

iTunes crashes with MediaControlSender AVSystemController_GetAirPlayInfo Aug 18, 2017

Add iterm2 marks to long-running outputs Jun 1, 2017

Trump Documents Atbash Decoded May 23, 2017

Polkit? WTF is this again? Actually... May 23, 2017

osacompile: no such component "JavaScript" May 2, 2017

" glxQueryVersion failed" with a headless chrome on alpine Mar 17, 2017

lighthouse/chromium/alpine/docker image Mar 9, 2017

Don't know how to build task '# Mar 6, 2017

sfdp: Error: Graphviz not built with triangulation library Jan 7, 2017

link_directory must be a directory Jan 2, 2017

Deactivating the Z170N's internal bluetooth in Clover Jul 3, 2016

Autogenerate a Dash Docset with Object Graph and documentation Statistics on Rails Migrate Jun 13, 2016

Massdrop is the worst spammer I've seen since the 90ies May 23, 2016

Verifying NGINX configurations in ansible May 23, 2016

ANSIBLE-MODULE-PATH and more Apr 29, 2016

'' is not a git command Apr 23, 2016

I rule (.svg) Mar 8, 2016

React and Relay error scrapbook Mar 3, 2016

Get a Grid, at least vertically Feb 17, 2016

Uncaught TypeError: Iterator value meps is not an entry object Nov 14, 2015

Controlled Jekyll Republishing with git Commit Messages Nov 2, 2015