-
-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (164 loc) · 7.63 KB
/
Copy pathdocumentation.yml
File metadata and controls
190 lines (164 loc) · 7.63 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
name: Documentation
# TEMPLATE: Customize for your project's documentation needs
# This workflow supports Doxygen (C/C++), but can be adapted for:
# - MkDocs (Python/Markdown)
# - Sphinx (Python)
# - JSDoc (JavaScript/TypeScript)
# - Javadoc (Java)
# - GoDoc (Go)
on:
push:
branches:
- main
- master # TEMPLATE: Adjust to your default branch
- develop
paths:
# TEMPLATE: Customize paths for your project structure
- "include/**" # C/C++ headers
- "src/**" # Source code
- "05-implementation/**" # Implementation documentation
- "08-transition/**" # User documentation
- "docs/**" # Documentation source files
- "Doxyfile" # Doxygen configuration
- "mkdocs.yml" # MkDocs configuration (if used)
- "scripts/generate-*.py"
- ".github/workflows/documentation.yml"
pull_request:
branches:
- main
- master
- develop
paths:
- "include/**"
- "src/**"
- "docs/**"
- "Doxyfile"
workflow_dispatch: # Allow manual trigger
# Cancel in-progress runs when a new workflow with the same group name is triggered
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-deploy:
name: Build and Deploy Documentation
runs-on: ubuntu-latest
permissions:
contents: write # Required for pushing to gh-pages branch
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for better diagrams
- name: Install Doxygen
run: |
sudo apt-get update
sudo apt-get install -y doxygen graphviz
- name: Verify Doxygen installation
run: |
doxygen --version
dot -V
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Check prerequisites
run: |
python scripts/generate-doxygen.py --check
- name: Generate documentation
run: |
python scripts/generate-doxygen.py --clean
- name: Check for warnings
run: |
if [ -f docs/doxygen/warnings.log ]; then
echo "### Doxygen Warnings" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat docs/doxygen/warnings.log >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
WARNING_COUNT=$(wc -l < docs/doxygen/warnings.log)
echo "Found $WARNING_COUNT warnings"
# Fail if there are warnings (can be adjusted)
# if [ $WARNING_COUNT -gt 0 ]; then
# echo "::error::Documentation has $WARNING_COUNT warnings"
# exit 1
# fi
else
echo "No warnings found!" >> $GITHUB_STEP_SUMMARY
fi
- name: Generate coverage report
run: |
python scripts/generate-doxygen.py --coverage | tee coverage.txt
echo "### Documentation Coverage" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat coverage.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Create .nojekyll file
run: |
# Prevent GitHub Pages from processing with Jekyll
touch docs/doxygen/html/.nojekyll
- name: Create custom index redirect
run: |
# Create root index.html that redirects to Doxygen index
# TEMPLATE: Customize title and description for your project
cat > docs/doxygen/html/redirect.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Project Documentation</title>
<meta http-equiv="refresh" content="0; url=./index.html">
<link rel="canonical" href="./index.html">
</head>
<body>
<p>Redirecting to <a href="./index.html">Project API Documentation</a>...</p>
</body>
</html>
EOF
- name: Deploy to GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/doxygen/html
publish_branch: gh-pages
force_orphan: true # Keep gh-pages branch clean
user_name: "github-actions[bot]"
user_email: "github-actions[bot]@users.noreply.github.com"
commit_message: "docs: update API documentation for ${{ github.sha }}"
- name: Upload documentation artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: documentation-pr-${{ github.event.pull_request.number }}
path: docs/doxygen/html/
retention-days: 30
- name: Comment on PR with documentation link
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const comment = `## 📚 Documentation Preview
Documentation has been generated for this PR.
**Download**: [Documentation Artifact](${artifactUrl})
To view locally:
1. Download the artifact from the workflow run
2. Extract the ZIP file
3. Open \`index.html\` in your browser
---
*Documentation will be automatically deployed to GitHub Pages when this PR is merged to main.*`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
- name: Add deployment info to summary
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
echo "### 🚀 Deployment Status" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Documentation successfully deployed to GitHub Pages!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "📖 **View Documentation**: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "🔗 **Direct Link**: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/index.html" >> $GITHUB_STEP_SUMMARY