1+ name : Documentation
2+
3+ on :
4+ push :
5+ branches : [ main, develop ]
6+ paths :
7+ - ' docs/**'
8+ - ' src/**'
9+ - ' .github/workflows/docs.yml'
10+ - ' pyproject.toml'
11+ pull_request :
12+ branches : [ main ]
13+ paths :
14+ - ' docs/**'
15+ - ' src/**'
16+ - ' .github/workflows/docs.yml'
17+ - ' pyproject.toml'
18+
19+ # Add permissions for GitHub Pages deployment
20+ permissions :
21+ contents : read
22+ pages : write
23+ id-token : write
24+
25+ jobs :
26+ build-docs :
27+ runs-on : ubuntu-latest
28+
29+ steps :
30+ - name : Checkout code
31+ uses : actions/checkout@v4
32+
33+ - name : Set up Python
34+ uses : actions/setup-python@v4
35+ with :
36+ python-version : ' 3.12'
37+
38+ - name : Install dependencies
39+ run : |
40+ python -m pip install --upgrade pip
41+ pip install -e .[docs]
42+
43+ - name : Check documentation coverage
44+ run : |
45+ cd docs
46+ make coverage
47+
48+ - name : Check for broken links
49+ run : |
50+ cd docs
51+ make linkcheck
52+ continue-on-error : true # Don't fail build on broken external links
53+
54+ - name : Build documentation
55+ run : |
56+ cd docs
57+ make html
58+
59+ - name : Check build warnings
60+ run : |
61+ cd docs
62+ if [ -s _build/html/.doctrees/warnings.txt ]; then
63+ echo "Documentation build has warnings:"
64+ cat _build/html/.doctrees/warnings.txt
65+ exit 1
66+ fi
67+ continue-on-error : true
68+
69+ - name : Upload documentation artifacts
70+ uses : actions/upload-artifact@v4
71+ with :
72+ name : documentation
73+ path : docs/_build/html/
74+
75+ deploy-docs :
76+ runs-on : ubuntu-latest
77+ needs : build-docs
78+ if : github.ref == 'refs/heads/main' && github.event_name == 'push'
79+
80+ # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
81+ permissions :
82+ pages : write # to deploy to Pages
83+ id-token : write # to verify the deployment originates from an appropriate source
84+
85+ # Configure environment for GitHub Pages deployment
86+ environment :
87+ name : github-pages
88+ url : ${{ steps.deployment.outputs.page_url }}
89+
90+ steps :
91+ - name : Download documentation artifacts
92+ uses : actions/download-artifact@v4
93+ with :
94+ name : documentation
95+ path : docs/_build/html/
96+
97+ - name : Setup Pages
98+ uses : actions/configure-pages@v4
99+
100+ - name : Upload to GitHub Pages
101+ uses : actions/upload-pages-artifact@v3
102+ with :
103+ path : docs/_build/html/
104+
105+ - name : Deploy to GitHub Pages
106+ id : deployment
107+ uses : actions/deploy-pages@v4
108+
109+ readthedocs-webhook :
110+ runs-on : ubuntu-latest
111+ needs : build-docs
112+ if : github.ref == 'refs/heads/main' && github.event_name == 'push'
113+
114+ steps :
115+ - name : Trigger ReadTheDocs build
116+ run : |
117+ curl -X POST \
118+ -H "Authorization: Token ${{ secrets.READTHEDOCS_TOKEN }}" \
119+ https://readthedocs.org/api/v3/projects/project-x-py/builds/
120+ continue-on-error : true # Don't fail if webhook isn't configured
0 commit comments