Add workflow to auto-regenerate lockfile for Dependabot PRs#312
Add workflow to auto-regenerate lockfile for Dependabot PRs#312umair-ably wants to merge 2 commits intomainfrom
Conversation
Dependabot sometimes fails to update the lockfile in pnpm workspace setups, causing CI to fail with frozen-lockfile errors (see PR #308). This workflow detects Dependabot PRs, runs pnpm install to regenerate the lockfile, and commits it back. Uses a GitHub App token so that subsequent CI runs are triggered automatically.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis PR adds a GitHub Actions workflow that automatically regenerates Changes
Review Notes
|
Review SummaryThis PR adds a GitHub Actions workflow to auto-regenerate
|
Lockfile resolution doesn't require running package scripts. Skipping them prevents a compromised upstream package from exfiltrating secrets available in the workflow environment.
|
@claude addressed your residual risk concern by adding |
There was a problem hiding this comment.
Review: Add workflow to auto-regenerate lockfile for Dependabot PRs
One real concern, one item to verify.
1. pull_request_target + PR branch checkout — security risk worth noting
The combination of pull_request_target (runs with secrets access in the base-branch context) and checking out the PR branch (ref: ${{ github.event.pull_request.head.ref }}) is a well-documented attack vector. If an attacker could trigger this workflow with a malicious package.json, they could potentially exfiltrate secrets.
In practice, the risk here is low because:
- The
if: github.actor == 'dependabot[bot]'guard limits execution to GitHub's own bot --ignore-scriptsprevents lifecycle scripts from running, which is the main exploit vector
But it's worth knowing this is non-zero risk if the Dependabot account or GitHub infrastructure were ever compromised. An alternative pattern that eliminates the exposure is a two-workflow design: a pull_request workflow that generates the new lockfile as an artifact, then a workflow_run workflow that commits it — but that's significantly more complex. Given the actor guard + --ignore-scripts, this is an acceptable tradeoff.
2. GitHub App permissions — verify before merging
The workflow reuses CLAUDE_APP_ID / CLAUDE_APP_PRIVATE_KEY (the Claude review app). This app needs Contents: write on the repo to push commits back to Dependabot branches. The PR description says this is intentional, but worth confirming the app actually has that permission configured. If it doesn't, the git push step will fail and the workflow will error out without regenerating the lockfile.
Everything else looks correct
- Action versions (
checkout@v6,setup-node@v6,create-github-app-token@v3) are consistent with the rest of the repo's workflows pnpm install --no-frozen-lockfile --ignore-scriptsis the right incantationgit add pnpm-lock.yaml(notgit add .) — only commits the lockfilegit diff --exit-code pnpm-lock.yaml && exit 0idempotency check is correcttimeout-minutes: 10guards against runaway jobs
|
@claude for point 2... i've raised a ticket so we create a minimally scoped github app to handle this instead of reusing the claude token... can you approve this as is for now? or should something else be addressed first? |
There was a problem hiding this comment.
Review: Add workflow to auto-regenerate lockfile for Dependabot PRs
No CLI source changes — command conventions don't apply here.
Summary
| File | Status | Issues |
|---|---|---|
.github/workflows/dependabot-lockfile.yml |
1 concern | GitHub App permissions may be insufficient |
pull_request_target + branch checkout — acceptable with mitigations
The classic security footgun: pull_request_target runs with secrets access, and this workflow checks out untrusted PR code. The mitigations are in place and correct:
if: github.actor == 'dependabot[bot]'limits execution to GitHub's own bot (unimpersonatable by external actors)--ignore-scriptsprevents lifecycle hooks from running — the main exploit vector
This is the recommended approach for Dependabot lockfile workflows. The risk is acceptable.
GitHub App permissions — verify before merging
The CLAUDE_APP_ID / CLAUDE_APP_PRIVATE_KEY secrets are already used in pr-overview.yml and claude-review.yml, but those workflows only need PR comment permissions (pull-requests: write). Pushing commits to a branch requires Contents: write on the installation.
If the Claude GitHub App was only granted PR/review permissions when it was set up, the git push step will fail with a 403. Worth confirming the app installation includes repository contents write access before merging — otherwise the workflow will error on every Dependabot PR without regenerating anything.
Everything else looks correct
- Action versions (
checkout@v6,setup-node@v6,pnpm/action-setup@v5) are consistent with all other workflows in this repo git add pnpm-lock.yaml(notgit add .) — only the lockfile gets committedgit diff --exit-code pnpm-lock.yaml && exit 0idempotency guard is correcttimeout-minutes: 10is sensible for a lockfile regeneration job
| id: generate-token | ||
| uses: actions/create-github-app-token@v3 | ||
| with: | ||
| app-id: ${{ secrets.CLAUDE_APP_ID }} |
There was a problem hiding this comment.
If we use these, it'll look like it's coming from Claude - which it isn't, I would probably look for the generic Ably CI account and use that
Summary
pnpm-lock.yamlwhen Dependabot opens a PR but fails to update the lockfile (as seen in fix(deps): bump the all-dependencies group across 1 directory with 9 updates #308)pull_request_targetwith an actor guard (dependabot[bot]) for securityHow it works
mainfromdependabot[bot]pnpm install --no-frozen-lockfileto regenerate the lockfilepnpm-lock.yamlchanged, commits and pushes it backTest plan
@dependabot recreateto get a fresh PR