#!/bin/bash -e
cd $(dirname "$0")
make html

TEMPFILE=$(tempfile)
rm -f $TEMPFILE
mkdir $TEMPFILE
cp -r ./_build/html/* "$TEMPFILE"
cd ../
git stash
git checkout gh-pages
rm -rf *
cp -r "$TEMPFILE/"* ./
git add .
git commit -m "Updated documents build"
git push origin gh-pages
git checkout master
git stash pop
