Skip to content

Commit 7eca92f

Browse files
committed
added docs workflow ofr autodeploy
1 parent 548d217 commit 7eca92f

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

.github/workflows/build_docs.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
mkdir -p ../.github/workflows/
2+
cat > ../.github/workflows/docs_pages_workflow.yml <<'EOF'
3+
name: build_docs
4+
5+
# execute this workflow automatically when a we push to master
6+
on:
7+
push:
8+
branches: [ master ]
9+
10+
jobs:
11+
12+
build_docs_job:
13+
runs-on: ubuntu-latest
14+
container: debian:buster-slim
15+
16+
steps:
17+
18+
- name: Prereqs
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
run: |
22+
apt-get update
23+
apt-get install -y git
24+
git clone --depth 1 "https://token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" .
25+
shell: bash
26+
27+
- name: Execute script to build our documentation and update pages
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
run: "docs/buildsite.sh"
31+
shell: bash
32+
EOF

docs/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ json:
7676
@echo
7777
@echo "Build finished; now you can process the JSON files."
7878

79+
github:
80+
@make html
81+
@cp -a build/html/. ./docs
82+
7983
htmlhelp:
8084
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
8185
@echo

docs/buildsite.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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

Comments
 (0)