Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Jekyll Sync Publish Cronjob
#!/usr/bin/env bash
# 0. cd into dir
dir=$(dirname $0)
cd $dir
# 1. Sync from master
git pull origin master
# 2. Get SHA's
sha=$(git log -n 1 --pretty=format:"%H")
if [ -f $file ]; then
sha_o=$(cat $file)
# 3. If sha's do not match update the site
if [ "$sha" != "$sha_o" ]; then
jekyll build
find _site/ -name '*.html' -exec sed -i.bak s/$\{sha\}/${sha}/g {} \;
find _site/ -name '*.bak' -exec rm -rf {} \;
rsync -avz _site/ /home/<sitename>/public_html/
rm -rf _site
echo "$sha" > $file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment