forked from lightspeedwp/.github
-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (118 loc) · 4.34 KB
/
Copy pathreadme-update.yml
File metadata and controls
143 lines (118 loc) · 4.34 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
name: README & Mermaid Updates
on:
workflow_dispatch:
inputs:
scope:
description: "Update scope (all/mermaid/staleness)"
required: true
default: "all"
type: choice
options:
- all
- mermaid
- staleness
dry_run:
description: "Preview changes without committing"
required: false
default: "false"
type: choice
options:
- "true"
- "false"
workflow_call:
inputs:
scope:
description: "Update scope (all/mermaid/staleness)"
required: false
default: "all"
type: string
dry_run:
description: "Preview changes without committing"
required: false
default: "false"
type: string
permissions:
contents: write
pull-requests: write
env:
DRY_RUN: ${{ inputs.dry_run || 'false' }}
UPDATE_SCOPE: ${{ inputs.scope || 'all' }}
jobs:
readme-update:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Install dependencies
run: npm ci
- name: Create audit directory
run: mkdir -p .github/reports/mermaid-audit
- name: Run Mermaid diagram fixes
if: ${{ env.UPDATE_SCOPE == 'all' || env.UPDATE_SCOPE == 'mermaid' }}
run: node .github/scripts/fix-mermaid-diagrams.js
continue-on-error: true
- name: Run staleness updates
if: ${{ env.UPDATE_SCOPE == 'all' || env.UPDATE_SCOPE == 'staleness' }}
run: node .github/scripts/fix-staleness-dates.js
continue-on-error: true
- name: Generate update report
if: success()
run: |
cat > .github/reports/mermaid-audit/update-report.md <<'EOF'
# README & Mermaid Update Report
**Date**: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
**Scope**: ${{ env.UPDATE_SCOPE }}
**Dry Run**: ${{ env.DRY_RUN }}
## Changes Summary
- Mermaid diagrams: Updated accessibility attributes (accTitle, accDescr)
- Staleness updates: Refreshed `last_updated` dates for files exceeding 6-month threshold
## Processing Mode
- **Dry Run**: ${{ env.DRY_RUN == 'true' && 'Yes (preview only)' || 'No (changes applied)' }}
- **Scope**: ${{ env.UPDATE_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/update-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: update READMEs with Mermaid accessibility and staleness fixes
- Update Mermaid diagrams with accTitle and accDescr attributes
- Refresh last_updated dates for stale files (6+ months)
- Scope: ${{ env.UPDATE_SCOPE }}
- Generated by: readme-update.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 report artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: readme-update-report
path: .github/reports/mermaid-audit/update-report.md
- name: Summary
run: |
echo "## README & Mermaid Update Workflow"
echo ""
echo "**Status**: ${{ job.status }}"
echo "**Scope**: ${{ env.UPDATE_SCOPE }}"
echo "**Dry Run**: ${{ env.DRY_RUN }}"
echo "**Changes Made**: ${{ steps.changes.outputs.has_changes }}"
echo ""
echo "📋 [Report](./.github/reports/mermaid-audit/update-report.md)"