-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathupdate_github_pages.sh
executable file
·52 lines (43 loc) · 1.47 KB
/
update_github_pages.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
cd "$(dirname "$0")"
SCRIPT_DIR="$(pwd)"
###############################################################################
# Create a workspace which is essentially just our gh-pages branch.
#
# For git workspace, see:
# https://gist.github.com/cobyism/4730490?permalink_comment_id=2375522#gistcomment-2375522
###############################################################################
if [[ ! -d dist ]]; then
git worktree add --quiet dist gh-pages
else
cd dist
git reset --hard HEAD
# Assure we pull the current branch from origin
git pull origin "$(git rev-parse --abbrev-ref HEAD)"
cd "${SCRIPT_DIR}"
fi
# Ensure that the worktree is relative. This is important
# to have it work in Docker containers as well.
if grep 'gitdir: /' dist/.git > /dev/null; then
sed -i.bak 's$/.*/.git$../.git$' ./dist/.git
rm ./dist/.git.bak
fi
###############################################################################
# Build HTML Docs from Sphinx Files
###############################################################################
./docs/create_changelog.sh
sphinx-build --color -b html "docs/source" "./dist"
rm -rf ./dist/.doctrees ./dist/.buildinfo
cd ./dist
git add .
if ! git diff --cached --quiet; then
git commit -m "New pages version $(date)"
git push origin gh-pages
# github.com recognizes gh-pages branch and create pages
# url scheme https//:[github-handle].github.io/[repository]
else
echo "Nothing to commit!"
fi
cd ..