Skip to content

Commit 82188ed

Browse files
hesreallyhimclaude
andcommitted
ci: gate badge regeneration on tests passing
- Merge snapshot-badges workflow into CI workflow - regenerate-badges job runs only after test job passes - Only triggers on pushes to main (not PRs) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 20d3cc4 commit 82188ed

File tree

3 files changed

+40
-44
lines changed

3 files changed

+40
-44
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ on:
55
branches: [main]
66
pull_request:
77
branches: [main]
8+
workflow_dispatch:
89

910
permissions:
10-
contents: read
11+
contents: write
1112

1213
jobs:
1314
test:
@@ -20,3 +21,35 @@ jobs:
2021
cache: npm
2122
- run: npm ci
2223
- run: npm test
24+
25+
regenerate-badges:
26+
needs: test
27+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version: 20
35+
36+
- name: Generate badge SVGs
37+
run: node scripts/snapshot-badges.js
38+
39+
- name: Check for changes
40+
id: changes
41+
run: |
42+
if git diff --quiet demo/src/assets/badges/; then
43+
echo "changed=false" >> $GITHUB_OUTPUT
44+
else
45+
echo "changed=true" >> $GITHUB_OUTPUT
46+
fi
47+
48+
- name: Commit and push
49+
if: steps.changes.outputs.changed == 'true'
50+
run: |
51+
git config user.name "github-actions[bot]"
52+
git config user.email "github-actions[bot]@users.noreply.github.com"
53+
git add demo/src/assets/badges/
54+
git commit -m "chore: regenerate demo badge assets"
55+
git push

.github/workflows/snapshot-badges.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

MAINTAINERS.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ The demo site uses pre-generated static SVG files rather than calling the live A
1212

1313
### Auto-regeneration
1414

15-
A GitHub workflow (`.github/workflows/snapshot-badges.yml`) automatically regenerates badge assets when `src/badges.js` or `src/utils.js` changes on main:
15+
The CI workflow (`.github/workflows/ci.yml`) includes a `regenerate-badges` job that runs after tests pass:
1616

1717
```
18-
Push to main (badge code changed)
19-
→ Workflow runs snapshot-badges.js
18+
Push to main
19+
→ Tests run
20+
→ If tests pass, regenerate-badges job runs
2021
→ If SVGs changed, commits and pushes
2122
→ Vercel sees commit, redeploys demo
2223
```
2324

25+
Badge regeneration only happens on pushes to main (not PRs) and only after tests pass.
26+
2427
### Manual regeneration
2528

2629
```bash

0 commit comments

Comments
 (0)