-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: django-doctor[bot] <72320148+django-doctor[bot]@users.noreply.github.com> Co-authored-by: Lint Action <github-action[bot]@github.com>
- Loading branch information
1 parent
5d1aad9
commit 3c2810b
Showing
2 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Github pages | ||
|
||
# execute this workflow automatically when a we push to master | ||
on: | ||
push: | ||
branches: [ master ] | ||
|
||
jobs: | ||
|
||
build_docs_job: | ||
runs-on: ubuntu-latest | ||
container: debian:buster-slim | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Execute script to build our documentation and update pages | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: "docs/buildDocs.sh" | ||
|
||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/bash | ||
################################################################################ | ||
# File: buildDocs.sh | ||
# Purpose: Script that builds our documentation using sphinx and updates GitHub | ||
# Pages. This script is executed by: | ||
# .github/workflows/docs_pages_workflow.yml | ||
# | ||
# Authors: Michael Altfield <michael@michaelaltfield.net> | ||
# Created: 2020-07-17 | ||
# Updated: 2020-07-17 | ||
# Version: 0.1 | ||
################################################################################ | ||
|
||
################### | ||
# INSTALL DEPENDS # | ||
################### | ||
|
||
apt-get update | ||
apt-get -y install git rsync python3-sphinx python3-sphinx-rtd-theme | ||
|
||
##################### | ||
# DECLARE VARIABLES # | ||
##################### | ||
|
||
pwd | ||
ls -lah | ||
# shellcheck disable=SC2155 | ||
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) | ||
|
||
############## | ||
# BUILD DOCS # | ||
############## | ||
|
||
# build our documentation with sphinx (see docs/conf.py) | ||
# * https://www.sphinx-doc.org/en/master/usage/quickstart.html#running-the-build | ||
make -C docs clean | ||
make -C docs html | ||
|
||
####################### | ||
# Update GitHub Pages # | ||
####################### | ||
|
||
git config --global user.name "${GITHUB_ACTOR}" | ||
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||
|
||
docroot=`mktemp -d` | ||
rsync -av "docs/_build/html/" "${docroot}/" | ||
|
||
pushd "${docroot}" || exit | ||
|
||
# don't bother maintaining history; just generate fresh | ||
git init | ||
git remote add deploy "https://token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | ||
git checkout -b gh-pages | ||
|
||
# add .nojekyll to the root so that github won't 404 on content added to dirs | ||
# that start with an underscore (_), such as our "_content" dir.. | ||
touch .nojekyll | ||
|
||
# Add README | ||
cat > README.md <<EOF | ||
# GitHub Pages Cache | ||
Nothing to see here. The contents of this branch are essentially a cache that's not intended to be viewed on github.com. | ||
If you're looking to update our documentation, check the relevant development branch's 'docs/' dir. | ||
For more information on how this documentation is built using Sphinx, Read the Docs, and GitHub Actions/Pages, see: | ||
* https://tech.michaelaltfield.net/2020/07/18/sphinx-rtd-github-pages-1 | ||
EOF | ||
|
||
# copy the resulting html pages built from sphinx above to our new git repo | ||
git add . | ||
|
||
# commit all the new files | ||
msg="Updating Docs for commit ${GITHUB_SHA} made on `date -d"@${SOURCE_DATE_EPOCH}" --iso-8601=seconds` from ${GITHUB_REF} by ${GITHUB_ACTOR}" | ||
git commit -am "${msg}" | ||
|
||
# overwrite the contents of the gh-pages branch on our github.com repo | ||
git push deploy gh-pages --force | ||
|
||
popd || exit # return to main repo sandbox root |