Skip to content

Instantly share code, notes, and snippets.

@cristobal
Created May 14, 2014 12:17
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 cristobal/83b3b9084a7281c6b929 to your computer and use it in GitHub Desktop.
Save cristobal/83b3b9084a7281c6b929 to your computer and use it in GitHub Desktop.
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")
sha_o="~"
file="sha.txt"
if [ -f $file ]; then
sha_o=$(cat $file)
fi
# 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
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment