This repository is currently being migrated. It's locked while the migration is in progress.
-
Notifications
You must be signed in to change notification settings - Fork 87
226 lines (186 loc) Β· 7.96 KB
/
pattern-adherence.yml
File metadata and controls
226 lines (186 loc) Β· 7.96 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
name: Update Pattern Adherence Tracking
on:
schedule:
# Run weekly on Mondays at 6 AM UTC (2 AM ET / 1 AM EDT)
- cron: '0 6 * * 1'
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
branches-ignore:
- 'pattern-adherence-update-**'
- '*pattern-adherence*'
paths:
- '.github/workflows/pattern-adherence.yml'
- 'scripts/collect-pattern-adherence.js'
- 'src/_patterns/**/*.md'
workflow_dispatch:
# Allow manual triggering for testing
jobs:
update-pattern-adherence:
runs-on: ubuntu-latest
# Skip if last commit was made by GitHub Action
if: |
github.event.head_commit.author.email != 'action@github.com' &&
!contains(github.event.head_commit.message, 'π Update pattern adherence data')
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.VADS_WORKFLOWS }}
ref: ${{ github.head_ref || github.ref_name }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Skip dependency installation
run: |
echo "π Pattern adherence script uses built-in Node.js modules only"
echo "π Skipping yarn install to avoid dependency conflicts"
echo "β
Node.js $(node --version) is ready"
- name: Setup GitHub CLI
run: |
echo "Using pre-installed GitHub CLI"
gh --version
env:
GITHUB_TOKEN: ${{ secrets.VADS_WORKFLOWS }}
- name: Verify GitHub CLI authentication
run: |
gh auth status
gh api user --jq '.login'
env:
GITHUB_TOKEN: ${{ secrets.VADS_WORKFLOWS }}
- name: Checkout vets-website (sparse - src/applications only)
uses: actions/checkout@v4
with:
repository: department-of-veterans-affairs/vets-website
path: vets-website
sparse-checkout: |
src/applications
sparse-checkout-cone-mode: false
fetch-depth: 1
- name: Create data directories
run: |
mkdir -p src/assets/data/metrics
mkdir -p src/_data/metrics
- name: Collect pattern adherence data
run: |
echo "Starting pattern adherence analysis..."
node scripts/collect-pattern-adherence.js --vets-website-path vets-website
echo "Pattern adherence analysis completed"
env:
GH_TOKEN: ${{ secrets.VADS_WORKFLOWS }}
- name: Verify generated data files
run: |
echo "Checking for generated files..."
ls -la src/assets/data/metrics/
if [ -f "src/assets/data/metrics/pattern-adherence.json" ]; then
echo "β
pattern-adherence.json generated"
echo "File size: $(du -h src/assets/data/metrics/pattern-adherence.json)"
else
echo "β pattern-adherence.json not found"
exit 1
fi
if [ -f "src/assets/data/metrics/pattern-adherence-report.md" ]; then
echo "β
pattern-adherence-report.md generated"
echo "File size: $(du -h src/assets/data/metrics/pattern-adherence-report.md)"
else
echo "β pattern-adherence-report.md not found"
exit 1
fi
- name: Check for changes
id: git-check
run: |
git add src/assets/data/metrics/pattern-adherence.json
git add src/assets/data/metrics/pattern-adherence-report.md
git add src/_data/metrics/pattern-adherence.json
if git diff --staged --quiet; then
echo "changes=false" >> $GITHUB_OUTPUT
echo "No changes detected"
else
echo "changes=true" >> $GITHUB_OUTPUT
echo "Changes detected"
git diff --staged --stat
fi
- name: Create branch and commit changes
if: steps.git-check.outputs.changes == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
CURRENT_DATE=$(date -u '+%Y-%m-%d')
BRANCH_NAME="pattern-adherence-update-${CURRENT_DATE}-${{ github.run_id }}"
git checkout -b "$BRANCH_NAME"
TOTAL_PATTERNS=$(jq -r '.total_patterns // "unknown"' src/assets/data/metrics/pattern-adherence.json)
TOTAL_FORMS=$(jq -r '.total_forms // "unknown"' src/assets/data/metrics/pattern-adherence.json)
git commit -m "π Update pattern adherence data - ${CURRENT_DATE}
- Analyzed ${TOTAL_PATTERNS} codified patterns
- Tracked ${TOTAL_FORMS} VA.gov forms
- Updated pattern-to-forms mapping
- Generated compliance reports
π€ Automated update via GitHub Actions"
git push origin "$BRANCH_NAME"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Create Pull Request
if: steps.git-check.outputs.changes == 'true'
run: |
CURRENT_DATE=$(date -u '+%Y-%m-%d %H:%M UTC')
PR_BODY="## Summary
Automated weekly update of pattern adherence tracking data.
### What Changed
- Pattern-to-forms mapping updated
- Compliance percentages recalculated
- Forms Γ Patterns matrix regenerated
### Files Updated
- \`src/assets/data/metrics/pattern-adherence.json\`
- \`src/assets/data/metrics/pattern-adherence-report.md\`
- \`src/_data/metrics/pattern-adherence.json\`
### Test Plan
- [ ] Verify JSON structure is valid
- [ ] Check markdown report renders correctly
- [ ] Review compliance percentages for accuracy
π€ Generated with automated workflow - ${CURRENT_DATE}"
gh pr create \
--title "π Update pattern adherence data - $(date -u '+%Y-%m-%d')" \
--body "$PR_BODY" \
--head "$BRANCH_NAME" \
--base main
PR_URL=$(gh pr view "$BRANCH_NAME" --json url --jq '.url')
echo "PR_URL=$PR_URL" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.VADS_WORKFLOWS }}
- name: Create summary
if: always()
run: |
echo "## π Pattern Adherence Update Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -f "src/assets/data/metrics/pattern-adherence.json" ]; then
TOTAL_PATTERNS=$(jq -r '.total_patterns // "unknown"' src/assets/data/metrics/pattern-adherence.json)
TOTAL_FORMS=$(jq -r '.total_forms // "unknown"' src/assets/data/metrics/pattern-adherence.json)
echo "### β
Pattern Adherence Data Updated" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Patterns Analyzed:** ${TOTAL_PATTERNS}" >> $GITHUB_STEP_SUMMARY
echo "- **Forms Tracked:** ${TOTAL_FORMS}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.git-check.outputs.changes }}" == "true" ]; then
echo "### π Pull Request Created" >> $GITHUB_STEP_SUMMARY
if [ -n "${PR_URL:-}" ]; then
echo "**PR URL:** $PR_URL" >> $GITHUB_STEP_SUMMARY
fi
else
echo "### βΉοΈ No Changes" >> $GITHUB_STEP_SUMMARY
echo "Pattern adherence data is up to date." >> $GITHUB_STEP_SUMMARY
fi
else
echo "### β Update Failed" >> $GITHUB_STEP_SUMMARY
echo "Pattern adherence data was not generated." >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### π
Next Update" >> $GITHUB_STEP_SUMMARY
echo "Next automatic update: Monday 6 AM UTC" >> $GITHUB_STEP_SUMMARY
- name: Notify on failure
if: failure()
run: |
echo "β Pattern adherence workflow failed"
echo "Check logs for details"