Skip to content

Commit 8dba0cc

Browse files
committed
Add docs build workflow for github actions
1 parent acef329 commit 8dba0cc

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/docs.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Sphinx Documentation to GitHub Pages
2+
on:
3+
push:
4+
# Build docs when pushing to `main` branch.
5+
branches: [ main ]
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Install dependencies (including Sphinx)
12+
uses: prefix-dev/setup-pixi@v0.9.1
13+
with:
14+
pixi-version: v0.49.0
15+
cache: true
16+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
17+
environments: docs
18+
- name: Sphinx build
19+
# Build HTML documentation from sources under `docs` to `build` folder.
20+
run: pixi run docs
21+
- name: Commit documentation in gh-pages branch
22+
# Store documentation in a temporary one-commit git repo.
23+
run: |
24+
cd docs/_build/html
25+
git init -b gh-pages
26+
touch .nojekyll
27+
git config --local user.name "GitHub Actions Bot"
28+
git config --local user.email "actions@github.com"
29+
git add .
30+
git commit -m "Update documentation"
31+
32+
- name: Push gh-pages branch
33+
# Push from the temporary repo to the `gh-pages` branch of your repo.
34+
# Warning: this will overwrite any existing content and history
35+
# of the `gh-pages` branch.
36+
run: |
37+
cd docs/_build/html
38+
git push --force "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}" gh-pages
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)