Add workflow to auto-regenerate lockfile for Dependabot PRs#312
Add workflow to auto-regenerate lockfile for Dependabot PRs#312umair-ably merged 3 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
Decouples lockfile regeneration from the Claude review bot credentials. The CI_PAT is a fine-grained token scoped to contents:write on this repo.
|
@claude review |
There was a problem hiding this comment.
Review (updated implementation)
No CLI source changes — TypeScript command conventions don't apply here. This is a pure GitHub Actions workflow review.
The PR has been updated since the initial reviews. Key changes from the earlier version:
--ignore-scriptsadded topnpm install— directly addresses the supply chain concern raised previously- Token switched from
CLAUDE_APP_ID/CLAUDE_APP_PRIVATE_KEYtosecrets.CI_PAT
Summary
| File | Status | Notes |
|---|---|---|
.github/workflows/dependabot-lockfile.yml |
OK | One pre-merge action item below |
--ignore-scripts resolves the prior supply chain concern
The previous review flagged that pnpm install could execute malicious lifecycle scripts from compromised upstream packages. Adding --ignore-scripts closes that vector — the lockfile is regenerated by resolving the dependency graph without running any package scripts. This is the right fix.
CI_PAT — confirm the secret exists before merging
secrets.CI_PAT is not referenced in any other workflow in this repository. Two possibilities:
- The secret already exists at the org/repo level (just never used in a workflow file before) — works as-is.
- The secret needs to be created — if it's missing,
actions/checkoutfalls back toGITHUB_TOKEN, the push will succeed, but the pushed commit won't trigger CI workflows (GITHUB_TOKEN pushes are excluded from workflow triggers by design). The lockfile gets regenerated but the CI run validating it never fires — defeating the stated purpose of using a PAT.
Worth confirming before merging. If CI_PAT is already provisioned, the workflow is ready to go.
Everything else is correct
if: github.actor == 'dependabot[bot]'at the job level is the right guard —[bot]suffix is GitHub-reserved and can't be spoofed by regular accounts- Dependabot creates branches within the same repo (not forks), so
ref: github.event.pull_request.head.refresolves correctly without needing an explicitrepository:input git add pnpm-lock.yaml(notgit add .) — only the lockfile gets committed backgit diff --exit-code pnpm-lock.yaml && exit 0idempotency guard is correcttimeout-minutes: 10is a sensible ceiling for lockfile regeneration- Action versions are consistent with the rest of this repo's workflows
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