1+ #! /bin/bash
2+ set -x
3+
4+ apt-get update
5+ apt-get -y install git rsync python3-sphinx
6+
7+ pwd ls -lah
8+ export SOURCE_DATE_EPOCH=$( git log -1 --pretty=%ct)
9+
10+ # #############
11+ # BUILD DOCS #
12+ # #############
13+
14+ # Python Sphinx, configured with source/conf.py
15+ # See https://www.sphinx-doc.org/
16+ make clean
17+ make html
18+
19+ # ######################
20+ # Update GitHub Pages #
21+ # ######################
22+
23+ git config --global user.name " test"
24+ git config --global user.email
" [email protected] " 25+
26+ docroot=` mktemp -d`
27+ rsync -av " build/html/" " ${docroot} /"
28+
29+ pushd " ${docroot} "
30+
31+ git init
32+ git remote add deploy " https://token:${GITHUB_TOKEN} @github.com/${GITHUB_REPOSITORY} .git"
33+ git checkout -b gh-pages
34+
35+ # Adds .nojekyll file to the root to signal to GitHub that
36+ # directories that start with an underscore (_) can remain
37+ touch .nojekyll
38+
39+ # Add README
40+ cat > README.md << EOF
41+ # README for the GitHub Pages Branch
42+ This branch is simply a cache for the website served from https://annegentle.github.io/create-demo/,
43+ and is not intended to be viewed on github.com.
44+ For more information on how this site is built using Sphinx, Read the Docs, and GitHub Actions/Pages, see:
45+ * https://www.docslikecode.com/articles/github-pages-python-sphinx/
46+ * https://tech.michaelaltfield.net/2020/07/18/sphinx-rtd-github-pages-1
47+ EOF
48+
49+ # Copy the resulting html pages built from Sphinx to the gh-pages branch
50+ git add .
51+
52+ # Make a commit with changes and any new files
53+ msg=" Updating Docs for commit ${GITHUB_SHA} made on ` date -d" @${SOURCE_DATE_EPOCH} " --iso-8601=seconds` from ${GITHUB_REF} by ${GITHUB_ACTOR} "
54+ git commit -am " ${msg} "
55+
56+ # overwrite the contents of the gh-pages branch on our github.com repo
57+ git push deploy gh-pages --force
58+
59+ popd # return to main repo sandbox root
60+
61+ # exit cleanly
62+ exit 0
0 commit comments