Skip to content

Commit 85a63d7

Browse files
committed
Generalize preview workflow; auto-regenerate generated files on main
preview-viz.yml only triggered on a feature branch that has since merged. Replace it with an on-demand Preview workflow taking the preview Worker name as a workflow_dispatch input. GitHub UI merges bypass the local git hooks that keep generated files fresh, so merges to main could land with stale asset fingerprints and a red Verify run. Add a workflow that reruns `make build` on push to main and commits the regenerated files when they drifted. https://claude.ai/code/session_012cj8czQW6Cd1Gw2PPgapED
1 parent 103f694 commit 85a63d7

2 files changed

Lines changed: 53 additions & 7 deletions

File tree

‎.github/workflows/preview.yml‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
name: Preview viz
1+
name: Preview
22

33
on:
4-
push:
5-
branches:
6-
- claude/tuftean-marginalia-viz-TB0fw
74
workflow_dispatch:
5+
inputs:
6+
name:
7+
description: Preview Worker name prefix
8+
required: false
9+
default: preview
10+
type: string
811

912
permissions:
1013
contents: read
1114

1215
concurrency:
13-
group: preview-viz
16+
group: preview-${{ inputs.name || 'preview' }}
1417
cancel-in-progress: true
1518

1619
jobs:
@@ -45,11 +48,11 @@ jobs:
4548
run: |
4649
set -x
4750
uv run pywrangler preview \
48-
--name viz \
51+
--name "${{ inputs.name || 'preview' }}" \
4952
--message "${{ github.sha }}" \
5053
--json
5154
- name: Smoke test deployed Preview
52-
run: scripts/smoke_deployment.py https://viz-pythonbyexample.adewale-883.workers.dev
55+
run: scripts/smoke_deployment.py "https://${{ inputs.name || 'preview' }}-pythonbyexample.adewale-883.workers.dev"
5356
- name: Dump wrangler logs on failure
5457
if: failure()
5558
run: |
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Regenerate generated files
2+
3+
# Merges made through the GitHub UI bypass the local git hooks that keep
4+
# src/asset_manifest.py and friends in sync, so a merge to main can land with
5+
# stale generated files (and a red Verify run). This workflow regenerates them
6+
# and pushes a fix-up commit. Pushes made with GITHUB_TOKEN do not trigger
7+
# other workflows, so the fix-up commit is not re-verified by CI; it only ever
8+
# contains deterministic `make build` output.
9+
10+
on:
11+
push:
12+
branches:
13+
- main
14+
15+
permissions:
16+
contents: write
17+
18+
concurrency:
19+
group: regenerate-generated-files
20+
cancel-in-progress: false
21+
22+
jobs:
23+
regenerate:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: '3.13'
30+
- name: Regenerate embedded examples and fingerprinted assets
31+
run: make build
32+
- name: Commit and push regenerated files if they drifted
33+
run: |
34+
git add -A src/example_sources_data.py src/asset_manifest.py public
35+
if git diff --cached --quiet; then
36+
echo "Generated files are current."
37+
exit 0
38+
fi
39+
git config user.name "github-actions[bot]"
40+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
41+
git commit -m "Regenerate fingerprinted assets"
42+
git pull --rebase origin main
43+
git push origin main

0 commit comments

Comments
 (0)