zrepl/docs/publish.sh

56 lines
1.1 KiB
Bash
Raw Normal View History

2017-08-09 16:13:12 +02:00
#!/bin/bash
set -eo pipefail
GHPAGESREPO="git@github.com:zrepl/zrepl.github.io.git"
SCRIPTDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
PUBLICDIR="${SCRIPTDIR}/public"
checkout_repo_msg() {
echo "checkout ${GHPAGESREPO} to ${PUBLICDIR}:"
echo " git clone ${GHPAGESREPO} ${PUBLICDIR}"
}
2017-08-09 16:13:12 +02:00
exit_msg() {
echo "error, exiting..."
}
trap exit_msg EXIT
cd "$SCRIPTDIR"
if [ ! -d "$PUBLICDIR" ]; then
checkout_repo_msg
exit 1
fi
2017-08-09 16:13:12 +02:00
echo -n "PRESS ENTER to confirm you commited the docs changes to the zrepl repo"
read
pushd "$PUBLICDIR"
2017-08-09 16:13:12 +02:00
echo "verify we're in the GitHub pages repo..."
git remote get-url origin | grep -E "^${GHPAGESREPO}\$"
if [ "$?" -ne "0" ] ;then
checkout_repo_msg
exit 1
fi
echo "resetting GitHub pages repo to latest commit"
git fetch origin
git reset --hard origin/master
2017-08-09 16:13:12 +02:00
echo "cleaning GitHub pages repo"
git clean -dn
popd
2017-08-09 16:13:12 +02:00
echo "building site"
hugo
pushd "$PUBLICDIR"
2017-08-09 16:13:12 +02:00
echo "adding and commiting all changes in GitHub pages repo"
git add -A
git commit -m "hugo render from publish.sh - `date -u`"
git push origin master