Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
executable file 81 lines (66 sloc) 2.41 KB
set -e
# this is a hack, but we have to make sure we're only ever running this from
# the top level of the package and not in the subdirectory...
if [[ ! -f gh_doc_automation/ ]]; then
echo "This must be run from the gh_doc_automation project directory"
exit 3
# get the running branch
branch=$(git symbolic-ref --short HEAD)
# cd into docs, make them
cd doc
make clean html EXAMPLES_PATTERN=ex_*
cd ..
# move the docs to the top-level directory, stash for checkout
mv doc/_build/html ./
# html/ will stay there actually...
git stash
# checkout gh-pages, remove everything but .git, pop the stash
# switch into the gh-pages branch
git checkout gh-pages
git pull origin gh-pages
# Make sure to set the credentials!
git config --global "$GH_EMAIL" > /dev/null 2>&1
git config --global "$GH_NAME" > /dev/null 2>&1
# remove all files that are not in the .git dir
find . -not -name ".git/*" -type f -maxdepth 1 -delete
# Remove the remaining directories. Some of these are artifacts of the LAST
# gh-pages build, and others are remnants of the package itself
declare -a leftover=(".cache/"
# check for each left over file/dir and remove it
for left in "${leftover[@]}"
rm -r "$left" || echo "$left does not exist; will not remove"
# we need this empty file for git not to try to build a jekyll project
touch .nojekyll
mv html/* ./
rm -r html/
# Add everything, get ready for commit. But only do it if we're on master
if [[ "$CIRCLE_BRANCH" =~ ^master$|^[0-9]+\.[0-9]+\.X$ ]]; then
git add --all
git commit -m "[ci skip] publishing updated documentation..."
# We have to re-add the origin with the GH_TOKEN credentials
git remote rm origin
git remote add origin https://"$GH_NAME":"$GH_TOKEN""$GH_NAME"/gh_automation.git
# NOW we should be able to push it
git push origin gh-pages
echo "Not on master, so won't push doc"