11# ########################################################################
22# Modified from Michael Altfield's work:
33# https://tech.michaelaltfield.net/2020/07/23/sphinx-rtd-github-pages-2/
4- # ########################################################################
4+ # ########################################################################
5+ FAILED=0
56echo " ::group::Build env info"
67pwd
78ls -lah
89echo " ::endgroup::"
910export SOURCE_DATE_EPOCH=$( git log -1 --pretty=%ct)
1011
1112# make a new temp dir which will be our GitHub Pages docroot
12- docroot=` mktemp -d`
13+ docroot=$( mktemp -d)
1314
1415export REPO_NAME=" ${GITHUB_REPOSITORY##*/ } "
1516
@@ -18,11 +19,11 @@ export REPO_NAME="${GITHUB_REPOSITORY##*/}"
1819# #############
1920
2021# get a list of branches, excluding 'HEAD' and 'gh-pages'
21- versions=" ` git for-each-ref ' --format=%(refname:lstrip=-1)' refs/remotes/origin/ refs/tags | grep -viE ' ^(HEAD|gh-pages)$' ` "
22+ versions=" $( git for-each-ref ' --format=%(refname:lstrip=-1)' refs/remotes/origin/ refs/tags | grep -viE ' ^(HEAD|gh-pages)$' ) "
2223for current_version in ${versions} ; do
2324 # make the current language available to conf.py
2425 export current_version
25- git checkout ${current_version} > /dev/null 2> /dev/null
26+ git checkout " ${current_version} " > /dev/null 2> /dev/null
2627
2728
2829 echo " ::group::Pre-build info for ${current_version} "
@@ -40,7 +41,7 @@ for current_version in ${versions}; do
4041 # #########
4142 # BUILDS #
4243 # #########
43- python ./build.py --latex --parallel --force-rebuild --emit-gh-annotations
44+ python ./build.py --latex --parallel --force-rebuild --emit-gh-annotations || FAILED=1
4445
4546 # HTML #
4647
@@ -66,7 +67,7 @@ git checkout latest
6667git config --global user.name " ${GITHUB_ACTOR} "
6768git config --global user.email " ${GITHUB_ACTOR} @users.noreply.github.com"
6869
69- pushd " ${docroot} "
70+ pushd " ${docroot} " || exit
7071
7172# don't bother maintaining history; just generate fresh
7273git init
@@ -109,14 +110,14 @@ EOF
109110git add .
110111
111112# commit all the new files
112- msg=" Updating Docs for commit ${GITHUB_SHA} made on ` date -d" @${SOURCE_DATE_EPOCH} " --iso-8601=seconds` from ${GITHUB_REF} by ${GITHUB_ACTOR} "
113+ msg=" Updating Docs for commit ${GITHUB_SHA} made on $( date -d" @${SOURCE_DATE_EPOCH} " --iso-8601=seconds) from ${GITHUB_REF} by ${GITHUB_ACTOR} "
113114git commit -am " ${msg} "
114115
115116# overwrite the contents of the gh-pages branch on our github.com repo
116117git push deploy gh-pages --force
117118echo " ::endgroup::"
118119
119- popd # return to main repo sandbox root
120+ popd || exit # return to main repo sandbox root
120121
121- # exit cleanly
122- exit 0
122+ # exit based on FAILED state
123+ exit $FAILED
0 commit comments