From 2ee7fee7ab1498710f048caeac98f46aee67bfa6 Mon Sep 17 00:00:00 2001 From: Saivann Date: Fri, 31 Jan 2014 20:14:05 -0500 Subject: [PATCH] Add new cron build script --- _contrib/build_website.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 _contrib/build_website.sh diff --git a/_contrib/build_website.sh b/_contrib/build_website.sh new file mode 100755 index 00000000..71e1b425 --- /dev/null +++ b/_contrib/build_website.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +REPO='https://github.com/bitcoin/bitcoin.org.git' +WORKDIR='/bitcoin.org' +DESTDIR='/var/www/bitcoinorg' + +# Stop script in case a single command fails +set -e + +export PATH=/var/lib/gems/1.8/bin/:$PATH + +# Clone repository if missing +if [ ! -d $WORKDIR ]; then + git clone $REPO $WORKDIR + cd $WORKDIR + git reset --hard HEAD~1 +fi + +cd $WORKDIR + +# Exit if no new commit is available +git fetch -a +LASTLOCALCOMMIT=`git log --format="%H" | head -n1` +LASTREMOTECOMMIT=`git log origin/master --format="%H" | head -n1` +if [ $LASTLOCALCOMMIT == $LASTREMOTECOMMIT ]; then + exit +fi + +# Update local branch +git reset --hard origin/master +git clean -x -f -d + +# Build website +jekyll +rsync --delete -a $WORKDIR/_site/ $DESTDIR/