ci: auto-regenerate snippets on dependabot PRs - #387
Open
ksroda-sa wants to merge 3 commits into
Open
Conversation
Bumping a library named in a samples/*/manifest.yaml `lib:` field changes the `lib_version` embedded in snippets.json, so the drift check in the `validate` job fails on an otherwise-fine dependency PR and blocks auto-merge until someone runs `cd scripts && yarn all` by hand. Add a `refresh-snippets` job that, for dependabot PRs only, re-runs aggregate + extract and pushes the result back to the PR branch. It keys off detected drift rather than matching package names, so there is no list of libraries to keep in sync and the per-scenario `lib:` overrides are covered too. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds CI automation to keep generated snippet artifacts (snippets.json / snippet-manifest.yaml) in sync on Dependabot PRs by regenerating and pushing updated artifacts back to the PR branch, unblocking required checks and auto-merge when dependency bumps change embedded library versions.
Changes:
- Introduces a
refresh-snippetsjob that runs onpull_requestevents authored bydependabot[bot]. - Re-runs
yarn aggregate+yarn extract, then commits and pushes regenerated artifacts when drift is detected.
Suppressed comments (1)
.github/workflows/extract.yml:100
- With
persist-credentials: false(or if checkout ends up detached), a plaingit pushcan fail or push to an unintended ref. Push explicitly to the PR branch and only after configuring auth for that push.
git commit -m "chore: regenerate snippets for dependency bump"
git push
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
.github/workflows/extract.yml:64
- The
refresh-snippetsjob will run on every Dependabot PR event, including thepull_request:synchronizeevent triggered by this workflow’s own push (wheregithub.actorbecomes the service account). That causes an extra (potentially repeated) fullyarn install/aggregate/extractrun even when there’s no drift, and increases the risk of a push loop if extraction output is ever non-deterministic. You can avoid this by (1) gating the job ongithub.actor == 'dependabot[bot]'and (2) running only whenvalidatefailed (typically due to drift), usingneeds+always()so the job still runs whenvalidatefails.
refresh-snippets:
if: >-
github.event_name == 'pull_request' &&
github.event.pull_request.user.login == 'dependabot[bot]'
runs-on: ubuntu-latest
ksroda-sa
marked this pull request as ready for review
August 21, 2026 15:04
ksroda-sa
requested review from
artursmolarek,
jgutikonda-sa,
jkotiuk,
justintvnguyen,
lgonczarik,
rharasani-sa and
twalshsa
August 21, 2026 15:04
svcdevopsgit1-sa
approved these changes
Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
snippets.jsonembeds alib_versionper framework, read from the sample'spackage.jsonfor the library named in that framework'smanifest.yamllib:field. When dependabot bumps one of those 12 libraries,yarn extractproduces a differentsnippets.json, so the Verify no drift step in thevalidatejob fails and auto-merge stalls until someone runscd scripts && yarn allby hand.Currently red for this reason: #385, #386, #383 (all three fixed by hand; this makes it automatic).
Change
A
refresh-snippetsjob inextract.ymlthat runs only on dependabot PRs, re-runs aggregate + extract, and pushes the regenerated artifacts back to the PR branch. The resulting commit re-runs the checks, they go green, and auto-merge proceeds.Notes on the approach:
lib:overrides (dotnet/java/node SAML) are covered for free.dependabot-auto-mergerun that commit triggers skips itself becausegithub.actoris then the service account, notdependabot[bot]. Without this step the PR ends up green but unapproved and no longer queued to merge.persist-credentials: false, so no write-scoped credential sits in.git/configwhileyarn installruns dependency build scripts.GH_SERVICE_ACCOUNT_DEVOPS_2_PAT1is supplied to the push and to theghcalls only. It is required —GITHUB_TOKENis read-only on dependabot events, and a push made with it would not re-trigger the required checks. Confirmed present in the Dependabot secret store (dependabot-auto-mergealready uses it and succeeds).validateis untouched. It still goes red on the pre-fix SHA; branch protection and auto-merge evaluate the new SHA, which is green.Side effect
Pushing to a dependabot branch stops dependabot from rebasing it further. Acceptable here — these PRs auto-merge immediately after.
🤖 Generated with Claude Code