Skip to content

Commit e9bcf9a

Browse files
authored
Merge pull request #37 from stonerlab/copilot/setup-sphinx-documentation-build
Add GitHub Actions workflow to build Sphinx documentation
2 parents 7365855 + 56ad9c6 commit e9bcf9a

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

.github/workflows/build-docs.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build Documentation
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: ['released', 'prereleased']
7+
8+
jobs:
9+
build-docs:
10+
name: Build Sphinx Documentation
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
defaults:
15+
run:
16+
shell: bash -l {0}
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
with:
22+
# For releases, check out the branch the release targets rather than the tag
23+
ref: ${{ github.event_name == 'release' && github.event.release.target_commitish || github.ref }}
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
fetch-depth: 0
26+
27+
- name: Set up conda environment
28+
uses: mamba-org/setup-micromamba@add3a49764cedee8ee24e82dfde87f5bc2914462 # v2.0.7
29+
with:
30+
environment-file: doc/docs-env.yml
31+
environment-name: docs-build
32+
create-args: >-
33+
python=3.12
34+
--channel-priority flexible
35+
init-shell: bash
36+
cache-downloads: true
37+
cache-environment: true
38+
39+
- name: Install package and remaining requirements
40+
run: pip install .
41+
42+
- name: Build documentation
43+
env:
44+
MPLBACKEND: Agg
45+
run: |
46+
cd doc
47+
make html
48+
49+
- name: Commit and push updated plot cache
50+
run: |
51+
git config user.name "github-actions[bot]"
52+
git config user.email "github-actions[bot]@users.noreply.github.com"
53+
git add doc/plot_cache/
54+
if ! git diff --staged --quiet; then
55+
git commit -m "Update documentation plot cache [skip ci]"
56+
git push || { echo "ERROR: git push failed. Ensure the workflow has 'contents: write' permission and branch protection rules allow this bot to push."; exit 1; }
57+
else
58+
echo "No changes to plot cache, skipping commit."
59+
fi

0 commit comments

Comments
 (0)