docs/scripts/deploy
#!/usr/bin/env bash
# note that $GITHUB_REPO contains an API key in it, so be careful to not allow
# that to end up as part of the output ever.
set -e
NAME=`git describe --exact-match 2> /dev/null || true`
DIR="${NAME}"
if [ -z "${NAME}" ]; then
NAME="master"
DIR="."
fi
if [ "`git rev-parse HEAD`" != "`git rev-parse ${NAME}~0 2> /dev/null`" ]; then
echo "Not deploying docs for non-master non-tagged commit `git rev-parse --short HEAD`"
exit 0
fi
mkdir -p deploy
cd deploy
git clone -q --depth 1 --branch gh-pages --single-branch $GITHUB_REPO .
git config user.name $GITHUB_NAME
git config user.email $GITHUB_EMAIL
# remove all old content before copying over new docs
if [ -d "${DIR}" ]; then
find "${DIR}" \
-type f \
-not -name CNAME \
-not -name README.md \
-not -path './.*' \
-not -path './v*/guides/**' \
-exec rm {} \;
fi
cp -r ../docs/build/* .
git add -A .
git commit -m 'Site updated' || echo 'No update required.'
git push -q origin gh-pages