Skip to content

Instantly share code, notes, and snippets.

@vallieres
Last active January 27, 2016 18:19
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 vallieres/61b341efdcfe35f01394 to your computer and use it in GitHub Desktop.
Save vallieres/61b341efdcfe35f01394 to your computer and use it in GitHub Desktop.
post-merge Hook Script for Jekyll Auto Build and Rsync. All details available here: https://hipsterpixel.co/2016/01/27/my-blog-publishing-workflow-on-ios-part-1-tutorial
#!/bin/bash
TZ=America/New_York
timestamp="$(date +"%s")"
touch ~/logs/user/jekyll_hp_$timestamp.log
SUBJECT="Hipster Pixel - Jekyll Update ($timestamp)"
EMAIL=" <enter your email here> "
echo -e "\n\n-----------------------------------------------------\n" > ~/logs/user/jekyll_hp_$timestamp.log
exec > >(tee -a ~/logs/user/jekyll_hp_$timestamp.log)
exec 2> >(tee -a ~/logs/user/jekyll_hp_$timestamp.log >&2)
date
. ~/.bash_profile
export LC_CTYPE=en_US.UTF-8
export LANG=en_US.UTF-8
unset LC_ALL
export GEM_HOME="/<where your Ruby gems are>/gems"
export HOME="<your home folder>"
export PATH=" <the path if different from your user's> "
echo -e "\nDeploying Jekyll Site\n"
# REPOSITORY_DIR is where your Git repo is located
REPOSITORY_DIR="/ <home> /<website>_git/.git"
# DEPLOY_DIR is where the Jekyll build result will go
DEPLOY_DIR="/ <home> /tmp/<website>_xyz/"
# DEPLOY_TMP_DIR is where the git clone command will drop the source
DEPLOY_TMP_DIR=$(mktemp / <home> /tmp/jekyll.deploy.XXXXX)
rm -f $DEPLOY_TMP_DIR
#rm -iRf $DEPLOY_DIR*
echo -e "\n\nCloning...\n"
git clone $REPOSITORY_DIR $DEPLOY_TMP_DIR
cd $DEPLOY_TMP_DIR
echo -e "\n\nRebuilding Jekyll...\n"
#bundle exec jekyll build -s $DEPLOY_TMP_DIR -d $DEPLOY_DIR 2>> ~/foo.log
#~/gems/bin/jekyll build -s $DEPLOY_TMP_DIR -d $DEPLOY_DIR 2>> ~/foo.log
jekyll build -s $DEPLOY_TMP_DIR -d $DEPLOY_DIR >> ~/logs/user/jekyll_hp_$timestamp.log
rm -rf $DEPLOY_TMP_DIR
cd $HOME
echo -e "\n\nRsyncing files...\n"
rsync -vrz --delete --checksum $DEPLOY_DIR / <where the LIVE site is located> /
echo -e "\n\nDone!\n"
date
echo " "
echo -e "--------------------------------------------------------\n\n"
mail -s "$SUBJECT" "$EMAIL" < ~/logs/user/jekyll_hp_$timestamp.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment