Skip to content

Commit 7f143b5

Browse files
committed
feat: add GitHub Actions workflow for building and deploying documentation
1 parent 508014e commit 7f143b5

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

.github/workflows/docs.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build and Deploy Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
jobs:
10+
docs:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout source
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up Python 3.11
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.11"
23+
24+
- name: Install Miniconda
25+
uses: conda-incubator/setup-miniconda@v3
26+
with:
27+
auto-update-conda: true
28+
python-version: "3.11"
29+
channels: conda-forge,cadwr-dms,nodefaults
30+
channel-priority: strict
31+
32+
- name: Create docs environment
33+
shell: bash -el {0}
34+
run: |
35+
conda env create -f environment-docs.yml
36+
conda run -n pydsm-docs pip install myst-parser sphinx-rtd-theme
37+
38+
- name: Install pydsm
39+
shell: bash -el {0}
40+
run: |
41+
conda run -n pydsm-docs pip install --no-deps -e .
42+
43+
- name: Generate sphinx-apidoc stubs
44+
shell: bash -el {0}
45+
run: |
46+
conda run -n pydsm-docs sphinx-apidoc -o docsrc pydsm --separate --force -q
47+
48+
- name: Pre-execute notebooks
49+
shell: bash -el {0}
50+
env:
51+
MPLBACKEND: Agg
52+
run: |
53+
for nb in docsrc/notebooks/*.ipynb; do
54+
echo "Executing $nb"
55+
conda run -n pydsm-docs \
56+
jupyter nbconvert --to notebook --execute --inplace \
57+
--ExecutePreprocessor.timeout=300 \
58+
--ExecutePreprocessor.kernel_name=python3 \
59+
"$nb"
60+
done
61+
62+
- name: Build HTML docs
63+
shell: bash -el {0}
64+
env:
65+
MPLBACKEND: Agg
66+
NBSPHINX_ALLOW_ERRORS: "0"
67+
run: |
68+
conda run -n pydsm-docs \
69+
python -msphinx -M html docsrc docsrc/_build
70+
71+
- name: Add .nojekyll and root redirect
72+
run: |
73+
touch docsrc/_build/.nojekyll
74+
echo '<meta http-equiv="refresh" content="0; url=./html/index.html" />' \
75+
> docsrc/_build/index.html
76+
77+
- name: Deploy to gh-pages
78+
uses: peaceiris/actions-gh-pages@v4
79+
with:
80+
github_token: ${{ secrets.GITHUB_TOKEN }}
81+
publish_dir: docsrc/_build
82+
publish_branch: gh-pages
83+
keep_files: false

0 commit comments

Comments
 (0)