Sha256: 01473cfbbc358de47b6f3e14e5bb60d6116e08ada90e706f982020d4c162b75f

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

#!/bin/sh
# get publish message to use
message=$1
if [ -z "$1" ]
then #if argument is empty
   #get the last commit message from this branch and use it as the commit to publish the site
   message=$(git log -n 1 --format="%s %n %n %b")
fi
# generate - just to make sure latest changes have been built
jekyll build --trace
#push the current branch to remote
git push
# get branch name into $branch -http://git-blame.blogspot.co.uk/2013/06/checking-current-branch-programatically.html
branch=$(git symbolic-ref --short -q HEAD)
tmp_d="/tmp/jsc"
#remove /tmp/jsc
rm -rf ${tmp_d}
mkdir ${tmp_d}
cp -r _site/. ${tmp_d}/
#checkout gh-pages
git checkout gh-pages
current_branch=$(git symbolic-ref --short -q HEAD)
if [[ "$current_branch" == *gh-pages* ]]
then
	#copy /tmp/jsc/* to current dir, replacing existing files
	cp -rv ${tmp_d}/. ./.
	# commit changes with message from command line or last commit msg
	git add -u
	git add .
	git commit -m "${message}"
	# push gh-pages branch
	git push
	# checkout $branch
	git checkout ${branch}
else
  red='\e[0;31m' #red - http://stackoverflow.com/a/5947802/400048
  NC='\e[0m' # No Color
  echo -e "${red}Failed to checkout gh-pages branch, site not published!${NC}"
fi
# remove /tmp/jsc
rm -rf ${tmp_d}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-scientific-0.0.3 bin/jsc_publish.sh