Skip to content

Commit 41e630f

Browse files
silv-ioclaude
andcommitted
Rebuild dist/ automatically on Dependabot PRs
Dependabot bumps of bundled dependencies (e.g. undici) always failed the "Check dist/" job until someone rebuilt dist/ by hand. Build dist/ in a read-only job with install scripts disabled, then push it back to the PR branch from a separate job that runs no npm code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 14a8eef commit 41e630f

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Dependabot updates package-lock.json but never rebuilds dist/, so every bump
2+
# of a bundled dependency fails the "Check dist/" job. This workflow rebuilds
3+
# dist/ on Dependabot PRs and pushes the result back to the PR branch.
4+
#
5+
# The build runs without write access and without dependency install scripts;
6+
# only the job that pushes gets a write token, and it runs no npm code.
7+
#
8+
# Pushes made with GITHUB_TOKEN do not trigger new workflow runs, so the new
9+
# head commit shows no checks. CI runs again on main after merging.
10+
name: Rebuild dist/ for Dependabot
11+
12+
on:
13+
pull_request:
14+
15+
permissions: {}
16+
17+
concurrency:
18+
group: dependabot-dist-${{ github.event.pull_request.number }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
build:
23+
name: Build dist/
24+
if: github.event.pull_request.user.login == 'dependabot[bot]'
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
29+
steps:
30+
- name: Checkout
31+
id: checkout
32+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
33+
with:
34+
persist-credentials: false
35+
36+
- name: Setup Node.js
37+
id: setup-node
38+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
39+
with:
40+
node-version-file: .node-version
41+
cache: npm
42+
43+
- name: Install Dependencies
44+
id: install
45+
run: npm ci --ignore-scripts
46+
47+
- name: Build dist/ Directory
48+
id: build
49+
run: npm run bundle
50+
51+
- name: Upload Artifact
52+
id: upload
53+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
54+
with:
55+
name: dist
56+
path: dist/
57+
58+
commit:
59+
name: Commit dist/
60+
needs: build
61+
runs-on: ubuntu-latest
62+
permissions:
63+
contents: write
64+
65+
steps:
66+
- name: Checkout
67+
id: checkout
68+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
69+
with:
70+
ref: ${{ github.event.pull_request.head.ref }}
71+
# needed for the push below; this job runs no dependency code
72+
persist-credentials: true # zizmor: ignore[artipacked]
73+
74+
- name: Download Artifact
75+
id: download
76+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
77+
with:
78+
name: dist
79+
path: dist/
80+
81+
- name: Commit and Push
82+
id: push
83+
run: |
84+
if git diff --quiet -- dist/; then
85+
echo "dist/ is already up to date"
86+
exit 0
87+
fi
88+
git config user.name 'github-actions[bot]'
89+
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
90+
git add dist/
91+
git commit -m 'Rebuild dist/'
92+
git push

0 commit comments

Comments
 (0)