Skip to content

Commit 33afa12

Browse files
committed
ci: add GitHub Actions workflow to deploy Sphinx docs to GitHub Pages
Dev-SHA: d58944ceb8e045a32e8804173e4fb9de65fb610a
1 parent 62e1bc3 commit 33afa12

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

.github/workflows/docs-deploy.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Deploy Docs to gh-pages
2+
3+
on:
4+
push:
5+
branches: [main, dev, v1.3.x]
6+
paths:
7+
- 'docs/sphinx/**'
8+
- '.github/workflows/docs-deploy.yml'
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: write
13+
14+
concurrency:
15+
group: gh-pages
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build-and-deploy:
20+
runs-on: ubuntu-24.04
21+
steps:
22+
- name: Checkout main/dev branch (2.x docs)
23+
uses: actions/checkout@v4
24+
with:
25+
path: src/2.x
26+
27+
- name: Checkout v1.3.x branch (1.x docs)
28+
id: checkout_1x
29+
continue-on-error: true
30+
uses: actions/checkout@v4
31+
with:
32+
ref: v1.3.x
33+
path: src/1.x
34+
35+
- uses: actions/setup-python@v5
36+
with:
37+
python-version: '3.12'
38+
39+
- name: Install dependencies
40+
run: pip install -r src/2.x/docs/sphinx/requirements.txt
41+
42+
- name: Strip 1.x from version switcher (no v1.3.x branch)
43+
if: steps.checkout_1x.outcome != 'success'
44+
run: |
45+
sed -i "/'<option value=\"1.x\">/d" \
46+
src/2.x/docs/sphinx/_templates/layout.html
47+
48+
- name: Build 2.x docs
49+
run: make -C src/2.x/docs/sphinx build
50+
# Output: src/2.x/docs/sphinx/_build/html/2.0/
51+
52+
- name: Build 1.x docs
53+
if: steps.checkout_1x.outcome == 'success'
54+
run: make -C src/1.x/docs/sphinx build
55+
# Output: src/1.x/docs/sphinx/_build/html/1.x/
56+
57+
- name: Assemble combined site
58+
run: |
59+
mkdir -p _site
60+
cp -r src/2.x/docs/sphinx/_build/html/2.0 _site/2.0
61+
if [ -d src/1.x/docs/sphinx/_build/html/1.x ]; then
62+
cp -r src/1.x/docs/sphinx/_build/html/1.x _site/1.x
63+
fi
64+
cp src/2.x/docs/sphinx/root_index.html _site/index.html
65+
touch _site/.nojekyll
66+
67+
- name: Deploy to gh-pages branch
68+
uses: peaceiris/actions-gh-pages@v4
69+
with:
70+
github_token: ${{ secrets.GITHUB_TOKEN }}
71+
publish_dir: _site
72+
publish_branch: gh-pages
73+
force_orphan: true

0 commit comments

Comments
 (0)