Skip to content

Commit fc35c38

Browse files
committed
workflows: Add documentation build workflow
Build documentation and push to gh-pages when merged to main. Signed-off-by: Jan Tore Guggedal <[email protected]>
1 parent 24026e5 commit fc35c38

File tree

3 files changed

+77
-36
lines changed

3 files changed

+77
-36
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Documentation Build
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
branches:
7+
- main
8+
paths:
9+
- '.github/workflows/docs-build-and-publish.yml'
10+
- 'docs/**'
11+
push:
12+
branches:
13+
- main
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Install dependencies
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get install -y python3 python3-pip
29+
30+
- name: Install Python dependencies
31+
working-directory: docs
32+
run: |
33+
python3 -m pip install -r requirements.txt
34+
35+
- name: Build documentation
36+
working-directory: docs
37+
run: |
38+
sphinx-build -M html . build
39+
40+
- name: Upload artifact
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: doc-build
44+
if-no-files-found: error
45+
retention-days: 2
46+
path: |
47+
docs/build/html/
48+
49+
- name: Update gh-pages
50+
if: ${{ github.event_name == 'push' }}
51+
env:
52+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
run: |
54+
git config --global --add safe.directory "$(pwd)"
55+
git config --global user.name "GitHub Actions"
56+
git config --global user.email "[email protected]"
57+
58+
git pull origin gh-pages
59+
60+
# Update docs
61+
rm -rf docs/html
62+
mkdir docs/html
63+
cp docs/build/html docs/html
64+
rm -rf docs/build
65+
66+
# Create commit with doc updates
67+
git add docs/html
68+
git commit -m "Updating documentation based on ${{ github.sha }}"
69+
70+
# Push changes
71+
git push origin gh-pages:gh-pages

docs/make.bat

Lines changed: 0 additions & 35 deletions
This file was deleted.

docs/requirements.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
Sphinx
1+
Sphinx==5.3.0
2+
breathe==4.35.0
3+
sphinx-ncs-theme<=0.7.4
4+
sphinx-tabs>=3.4
5+
sphinx-togglebutton>=0.3.2
6+
Pillow>=9.0.1

0 commit comments

Comments
 (0)