-
Notifications
You must be signed in to change notification settings - Fork 2
210 lines (180 loc) · 6.88 KB
/
Copy pathdocs.yml
File metadata and controls
210 lines (180 loc) · 6.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
name: Build and Deploy Documentation
on:
push:
branches: [main, develop, dev]
pull_request:
branches: [main, develop, dev]
workflow_dispatch:
# Add permissions for GitHub Pages
permissions:
contents: read
pages: write
id-token: write
jobs:
build-and-deploy-docs:
runs-on: ubuntu-latest
# Only deploy on main branch pushes
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# Use concurrency to cancel in-progress deployments
concurrency:
group: "pages"
cancel-in-progress: false
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Configure Git identity (global)
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global init.defaultBranch main
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
if [ -f "docs/requirements.txt" ]; then
pip install -r docs/requirements.txt
else
echo "docs/requirements.txt not found, installing default dependencies"
pip install sphinx furo sphinx-rtd-theme breathe exhale
fi
- name: Install Doxygen and Graphviz
run: |
sudo apt-get update
sudo apt-get install -y doxygen graphviz
- name: Check for Doxyfile
id: check_doxyfile
run: |
if [ -f "Doxyfile" ]; then
echo "doxyfile_exists=true" >> $GITHUB_OUTPUT
echo "Doxyfile found, will generate API documentation"
else
echo "doxyfile_exists=false" >> $GITHUB_OUTPUT
echo "Doxyfile not found, skipping API documentation generation"
fi
- name: Generate Doxygen XML and HTML (if Doxyfile exists)
if: steps.check_doxyfile.outputs.doxyfile_exists == 'true'
run: |
doxygen Doxyfile || echo "Doxygen generation failed, continuing without API docs"
if [ -d "docs/xml" ]; then
echo "Doxygen XML generated successfully"
else
echo "Warning: Doxygen XML directory (docs/xml/) not found, API docs will be skipped"
fi
if [ -d "docs/html" ]; then
echo "Doxygen HTML generated successfully"
else
echo "Warning: Doxygen HTML directory (docs/html/) not found"
fi
- name: Verify Doxygen XML Output (if generated)
if: steps.check_doxyfile.outputs.doxyfile_exists == 'true'
run: |
if [ -d "docs/xml" ] && [ -n "$(ls -A docs/xml/ 2>/dev/null)" ]; then
echo "Doxygen XML files generated successfully."
else
echo "Warning: Doxygen XML directory is empty or missing, API docs will be skipped"
fi
- name: Create static directories
working-directory: docs
run: |
mkdir -p _static _templates api/doxygen
# Copy logo if it exists
if [ -f "../resources/ot-logo.svg" ]; then
cp ../resources/ot-logo.svg _static/ot-logo.svg
echo "Logo copied to _static/"
else
echo "Logo not found, continuing without logo"
fi
# Copy any existing SVGs from doxygen output
if [ -d "../docs/html" ]; then
cp -r ../docs/html/*.svg _static/ 2>/dev/null && echo "SVGs copied to _static/" || echo "No SVGs found in docs/html/, continuing"
fi
- name: Build Sphinx HTML
working-directory: docs
run: |
make html SPHINXOPTS="-W --keep-going" || make html || echo "Sphinx build completed with warnings"
if [ ! -d "_build/html" ]; then
echo "Error: HTML generation failed: _build/html/ directory not found."
exit 1
fi
echo "Sphinx HTML build completed successfully."
- name: Build Sphinx Markdown (optional)
working-directory: docs
continue-on-error: true
run: |
sphinx-build -b markdown . _build/markdown -W --keep-going || echo "Markdown build failed, continuing"
if [ -d "_build/markdown" ] && [ -z "$(ls -A _build/markdown 2>/dev/null)" ]; then
rm -rf _build/markdown
echo "Markdown directory was empty and removed"
fi
- name: Upload Documentation Artifacts
uses: actions/upload-artifact@v4
with:
name: documentation
path: |
docs/_build/html/
docs/_build/markdown/
if-no-files-found: warn
# Setup GitHub Pages
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload to GitHub Pages
uses: actions/upload-pages-artifact@v3
with:
path: docs/_build/html
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
build-docs-only:
runs-on: ubuntu-latest
# Build docs on PRs and non-main branch pushes without deploying
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref != 'refs/heads/main')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
if [ -f "docs/requirements.txt" ]; then
pip install -r docs/requirements.txt
else
echo "docs/requirements.txt not found, installing default dependencies"
pip install sphinx furo sphinx-rtd-theme breathe exhale
fi
- name: Install Doxygen and Graphviz
run: |
sudo apt-get update
sudo apt-get install -y doxygen graphviz
- name: Create static directories
working-directory: docs
run: |
mkdir -p _static _templates api/doxygen
if [ -f "../resources/ot-logo.svg" ]; then
cp ../resources/ot-logo.svg _static/ot-logo.svg
fi
- name: Build Sphinx HTML (check only)
working-directory: docs
run: |
make html SPHINXOPTS="-W --keep-going" || make html
if [ ! -d "_build/html" ]; then
echo "Error: HTML generation failed: _build/html/ directory not found."
exit 1
fi
echo "Sphinx HTML build check completed successfully."
- name: Upload Documentation Artifacts
uses: actions/upload-artifact@v4
with:
name: documentation-preview
path: docs/_build/html/
if-no-files-found: warn