Skip to content

Instantly share code, notes, and snippets.

@aramk
Last active May 9, 2017 16:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aramk/5659983 to your computer and use it in GitHub Desktop.
Save aramk/5659983 to your computer and use it in GitHub Desktop.
Publishing Jekyll to gh-pages branch
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
SELF=`basename $0`
SOURCE_BRANCH="master"
DEST_BRANCH="gh-pages"
TMP_DIR="tmp"
git checkout $SOURCE_BRANCH
jekyll build -d $TMP_DIR
git checkout $DEST_BRANCH
# This will remove previous files, which we may not want (e.g. CNAME)
# git rm -qr .
cp -r $TMP_DIR/. .
# Delete this script from the output
rm ./$SELF
rm -r $TMP_DIR
git add -A
git commit -m "Published updates"
# May not want to push straight away
# git push origin master
git checkout $SOURCE_BRANCH
@alexanmtz
Copy link

great script!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment