Repository navigation
363 lines (308 loc) · 11.9 KB
/
Copy pathdocumentation.yml
File metadata and controls
363 lines (308 loc) · 11.9 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
name: Documentation Validation & Maintenance
on:
workflow_dispatch:
inputs:
action:
description: "Action to perform"
required: true
type: choice
options:
- audit
- maintain
scope:
description: "Scope (audit: all/syntax/accessibility/contrast/staleness; maintain: all/mermaid/staleness)"
required: false
default: "all"
type: string
dry_run:
description: "Preview changes without committing (maintain action only)"
required: false
default: "false"
type: choice
options:
- "true"
- "false"
pull_request:
branches:
- develop
types: [opened, edited, synchronize, reopened, ready_for_review]
paths:
- "**/*.md"
- ".github/workflows/**"
- ".github/agents/**"
- ".github/instructions/**"
- "docs/**"
- "scripts/**"
push:
branches:
- develop
paths:
- "**/*.md"
- ".github/workflows/**"
- ".github/agents/**"
- ".github/instructions/**"
- "docs/**"
- "scripts/**"
permissions:
contents: read
concurrency:
group: documentation-${{ github.ref }}
cancel-in-progress: true
env:
ACTION: ${{ github.event.inputs.action || 'regenerate' }}
AUDIT_SCOPE: ${{ github.event.inputs.scope || 'all' }}
DRY_RUN: ${{ github.event.inputs.dry_run || 'false' }}
jobs:
audit:
name: Documentation Audit
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && github.event.inputs.action == 'audit'
permissions:
contents: read
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Create audit directory
run: mkdir -p .github/reports/mermaid-audit
- name: Run README audit
id: audit
if: contains(fromJson('["all", "audit"]'), env.AUDIT_SCOPE)
run: |
npm run audit:readme -- \
--scope=${{ env.AUDIT_SCOPE }} \
--format=markdown \
--output=.github/reports/mermaid-audit/
continue-on-error: true
- name: Validate Mermaid syntax
id: syntax
if: contains(fromJson('["all", "syntax"]'), env.AUDIT_SCOPE)
run: npm run validate:mermaid-syntax
- name: Check WCAG compliance
id: accessibility
if: contains(fromJson('["all", "accessibility"]'), env.AUDIT_SCOPE)
run: npm run validate:mermaid-accessibility
- name: Check Mermaid colour contrast
id: contrast
if: contains(fromJson('["all", "contrast"]'), env.AUDIT_SCOPE)
run: npm run validate:mermaid-contrast
- name: Identify stale documents
id: staleness
if: contains(fromJson('["all", "staleness"]'), env.AUDIT_SCOPE)
run: |
echo "Checking for stale README files (>6 months old)..."
find . -name "README.md" -type f | while read file; do
echo "Checking staleness for $file..."
done
- name: Check validation outcomes
id: validation-status
if: always()
env:
SYNTAX_OUTCOME: ${{ steps.syntax.outcome }}
A11Y_OUTCOME: ${{ steps.accessibility.outcome }}
CONTRAST_OUTCOME: ${{ steps.contrast.outcome }}
run: node scripts/collect-validation-results.js >> "$GITHUB_OUTPUT"
- name: Generate audit report
if: always()
env:
SYNTAX_PASSED: ${{ steps.validation-status.outputs.syntax_ok }}
A11Y_PASSED: ${{ steps.validation-status.outputs.a11y_ok }}
CONTRAST_PASSED: ${{ steps.validation-status.outputs.contrast_ok }}
AUDIT_SCOPE: ${{ env.AUDIT_SCOPE }}
run: node scripts/generate-doc-audit-report.js >> "$GITHUB_STEP_SUMMARY"
- name: Upload audit artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: documentation-audit-report-${{ github.run_number }}
path: .github/reports/mermaid-audit/
retention-days: 30
- name: Create issue for critical findings
if: failure()
uses: actions/github-script@v9
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '🚨 Critical Findings from Documentation Audit',
body: 'Documentation audit workflow found critical issues. See audit report artifacts.',
labels: ['type:bug', 'area:documentation', 'priority:critical']
})
regenerate:
name: Auto-regenerate Documentation
runs-on: ubuntu-latest
if: |
github.event_name == 'pull_request' ||
(github.event_name == 'push' && github.ref == 'refs/heads/develop')
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: true
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Resolve impacted README files
id: readmes
env:
EVENT_NAME: ${{ github.event_name }}
PR_BASE: ${{ github.event.pull_request.base.sha }}
PR_HEAD: ${{ github.event.pull_request.head.sha }}
PUSH_BEFORE: ${{ github.event.before }}
PUSH_SHA: ${{ github.sha }}
run: node scripts/workflows/resolve-readme-files.cjs
- name: Run README regeneration (PR dry-run)
if: steps.readmes.outputs.files != '' && github.event_name == 'pull_request'
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_REF_NAME: ${{ github.ref_name }}
README_FILES: ${{ steps.readmes.outputs.files }}
run: node scripts/agents/meta.agent.js --dry-run --files "$README_FILES"
- name: Run README regeneration (push commit)
if: steps.readmes.outputs.files != '' && github.event_name == 'push'
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_REF_NAME: ${{ github.ref_name }}
README_FILES: ${{ steps.readmes.outputs.files }}
run: node scripts/agents/meta.agent.js --files "$README_FILES"
- name: Commit README updates
if: github.event_name != 'pull_request' && steps.readmes.outputs.files != ''
run: |
git config user.name "lightspeed-bot"
git config user.email "ops@lightspeedwp.agency"
git add -A
if ! git diff --cached --quiet; then
git commit -m "chore(docs): regenerate impacted README files [skip ci]"
git push origin ${{ github.ref_name }}
fi
- name: Upload regeneration artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: documentation-regeneration-${{ github.run_number }}
path: .github/reports/
if-no-files-found: ignore
retention-days: 14
maintain:
name: Documentation Maintenance
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && github.event.inputs.action == 'maintain'
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: true
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Create audit directory
run: mkdir -p .github/reports/mermaid-audit
- name: Run Mermaid diagram fixes
id: mermaid
if: ${{ env.AUDIT_SCOPE == 'all' || env.AUDIT_SCOPE == 'mermaid' }}
run: node scripts/fix-mermaid-diagrams.cjs
continue-on-error: true
- name: Validate Mermaid colour contrast
id: contrast
if: ${{ env.AUDIT_SCOPE == 'all' || env.AUDIT_SCOPE == 'mermaid' }}
run: npm run validate:mermaid-contrast
continue-on-error: true
- name: Run staleness updates
id: staleness
if: ${{ env.AUDIT_SCOPE == 'all' || env.AUDIT_SCOPE == 'staleness' }}
run: node scripts/fix-staleness-dates.cjs
continue-on-error: true
- name: Generate maintenance report
if: always()
run: |
REPORT_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
MERMAID_STATUS="${{ steps.mermaid.outcome || 'skipped' }}"
CONTRAST_STATUS="${{ steps.contrast.outcome || 'skipped' }}"
STALENESS_STATUS="${{ steps.staleness.outcome || 'skipped' }}"
AUDIT_SCOPE="${{ env.AUDIT_SCOPE }}"
DRY_RUN="${{ env.DRY_RUN }}"
DRY_RUN_LABEL=$([ "$DRY_RUN" = "true" ] && echo "Yes (preview only)" || echo "No (changes applied)")
cat > .github/reports/mermaid-audit/maintenance-report.md <<EOF
# Documentation Maintenance Report
**Date**: ${REPORT_DATE}
**Scope**: ${AUDIT_SCOPE}
**Dry Run**: ${DRY_RUN}
## Processing Status
| Task | Status |
|------|--------|
| Mermaid Diagrams | ${MERMAID_STATUS} |
| Contrast Validation | ${CONTRAST_STATUS} |
| Staleness Updates | ${STALENESS_STATUS} |
## Changes Summary
- Mermaid diagrams: Updated accessibility attributes and colour-contrast-safe palette values
- Staleness updates: Refreshed \`last_updated\` dates for files exceeding 6-month threshold
## Processing Mode
- **Dry Run**: ${DRY_RUN_LABEL}
- **Scope**: ${AUDIT_SCOPE}
## Next Steps
If changes were applied:
1. Review the changes in this run's artifacts
2. Create a pull request with the updates
3. Have maintainers review and merge
EOF
cat .github/reports/mermaid-audit/maintenance-report.md
- name: Check for changes
id: changes
run: test "$(git status --porcelain | wc -l)" -gt 0 && echo "has_changes=true" >> "$GITHUB_OUTPUT" || echo "has_changes=false" >> "$GITHUB_OUTPUT"
- name: Commit changes
if: ${{ steps.changes.outputs.has_changes == 'true' && env.DRY_RUN == 'false' }}
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add -A
git commit -m "docs: maintenance updates (Mermaid + staleness)
- Update Mermaid diagrams with accTitle, accDescr, and approved palette values
- Refresh last_updated dates for stale files (6+ months)
- Scope: ${{ env.AUDIT_SCOPE }}
- Generated by: documentation.yml workflow"
- name: Push changes
if: ${{ steps.changes.outputs.has_changes == 'true' && env.DRY_RUN == 'false' }}
run: |
git push origin HEAD:$(git rev-parse --abbrev-ref HEAD)
- name: Upload maintenance report
if: always()
uses: actions/upload-artifact@v7
with:
name: documentation-maintenance-report-${{ github.run_number }}
path: .github/reports/mermaid-audit/
- name: Maintenance summary
if: always()
run: |
echo "## Documentation Maintenance Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Status**: ${{ job.status }}" >> $GITHUB_STEP_SUMMARY
echo "**Scope**: ${{ env.AUDIT_SCOPE }}" >> $GITHUB_STEP_SUMMARY
echo "**Dry Run**: ${{ env.DRY_RUN }}" >> $GITHUB_STEP_SUMMARY
echo "**Changes Made**: ${{ steps.changes.outputs.has_changes }}" >> $GITHUB_STEP_SUMMARY