Created
May 14, 2014 12:17
-
-
Save cristobal/83b3b9084a7281c6b929 to your computer and use it in GitHub Desktop.
Jekyll Sync Publish Cronjob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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