Skip to content

Commit 7222c6d

Browse files
committed
add(ci): build and deploy documentation using GH Actions and Pages
1 parent e077a29 commit 7222c6d

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: "📚 Documentation"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- ".github/workflows/documentation.yml"
9+
- "docs/*/**"
10+
- "profile_manager/**/*.py"
11+
- "profile_manager/metadata.txt"
12+
- "requirements/documentation.txt"
13+
tags:
14+
- "*"
15+
16+
pull_request:
17+
branches:
18+
- main
19+
paths:
20+
- ".github/workflows/documentation.yml"
21+
- docs/**/*
22+
- requirements/documentation.txt
23+
24+
workflow_dispatch:
25+
26+
workflow_run:
27+
workflows:
28+
- "Packager 📦"
29+
types:
30+
- completed
31+
32+
# Allow one concurrent deployment per branch/pr
33+
concurrency:
34+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
35+
cancel-in-progress: true
36+
37+
env:
38+
PROJECT_FOLDER: "profile_manager"
39+
PYTHON_VERSION: 3.9
40+
41+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
42+
permissions:
43+
contents: read
44+
pages: write
45+
id-token: write
46+
47+
jobs:
48+
build:
49+
runs-on: ubuntu-latest
50+
51+
steps:
52+
- name: Get source code
53+
uses: actions/checkout@v4
54+
55+
- name: Set up Python
56+
uses: actions/setup-python@v5
57+
with:
58+
cache: "pip"
59+
cache-dependency-path: "requirements/documentation.txt"
60+
python-version: ${{ env.PYTHON_VERSION }}
61+
62+
- name: Install dependencies
63+
run: |
64+
python -m pip install --upgrade pip setuptools wheel
65+
python -m pip install -U -r requirements/documentation.txt
66+
67+
- name: Build doc using Sphinx
68+
run: sphinx-build -b html -d docs/_build/cache -j auto docs docs/_build/html
69+
70+
- name: Save build doc as artifact
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: documentation
74+
path: docs/_build/html/*
75+
if-no-files-found: error
76+
retention-days: 30
77+
78+
- name: Download artifact from build workflow
79+
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
80+
uses: dawidd6/action-download-artifact@v9
81+
with:
82+
allow_forks: false
83+
branch: main
84+
event: push
85+
github_token: ${{ secrets.GITHUB_TOKEN }}
86+
if_no_artifact_found: warn
87+
name: ${{ env.PROJECT_FOLDER }}-latest
88+
path: docs/_build/html/
89+
# run_id: ${{ github.event.workflow_run.id }}
90+
workflow: package_and_release.yml
91+
92+
- name: Setup Pages
93+
uses: actions/configure-pages@v5
94+
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
95+
96+
- name: Upload artifact
97+
uses: actions/upload-pages-artifact@v3
98+
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
99+
with:
100+
path: docs/_build/html/
101+
102+
- name: Deploy to GitHub Pages
103+
id: deployment
104+
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
105+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)