-
Notifications
You must be signed in to change notification settings - Fork 8
/
github-pages-publish.sh
executable file
·34 lines (25 loc) · 906 Bytes
/
github-pages-publish.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
set -euo pipefail
declare SITE=${1:-site.yml}
declare REPO=${2:-$(git remote get-url origin)}
declare BRANCH="gh-pages"
declare _CURR_DIR="$( cd "$(dirname "$0")" ; pwd -P )"
# NOTE: WORKSPACE_ROOT defined from devcontainer.json if running from within vscode
declare REPO_ROOT=${WORKSPACE_ROOT:-${_CURR_DIR}}
echo "Removing old publish directory"
if [[ -d $REPO_ROOT/gh-pages ]]; then
rm -rf $REPO_ROOT/gh-pages
fi
echo "Removing antora cache directory"
if [[ -d $REPO_ROOT/.cache ]]; then
rm -rf $REPO_ROOT/.cache
fi
git clone -b ${BRANCH} ${REPO} $REPO_ROOT/gh-pages
echo "Generating the site documentation from ${SITE}"
antora generate --stacktrace $REPO_ROOT/${SITE} --to-dir $REPO_ROOT/gh-pages
echo "Pushing site to ${BRANCH} branch of ${REPO}"
cd $REPO_ROOT/gh-pages
git add --all .
git commit -m"Automated Publish"
git push origin
echo "Site published successfully!"