ci: automate the lock-file fix that keeps breaking Dependabot's nuget PRs - #130
Merged
Conversation
… PRs Dependabot regenerates packages.lock.json only for the projects whose .csproj it edits; every project consuming the bumped package transitively keeps its old lock file, and locked-mode restore fails the solution with NU1004. Grouping (#126) turned five such pull requests into one - this closes the loop on that one. The failure is not hypothetical: it broke three workflows across two branches on 2026-08-17 alone, and the fix each time was the same mechanical `dotnet restore --force-evaluate` done by hand. dependabot-lockfix.yml (default branch only, by workflow_run's rules) fires on any failed API/CodeQL/container run of a dependabot/nuget/** branch, regenerates the lock files, pushes the fix, and re-dispatches every required check on the fixed commit. The three GitHub constraints that dictate the shape are documented in the file: dependabot-actor runs get read-only tokens (hence workflow_run), GITHUB_TOKEN pushes trigger no workflows (hence explicit re-dispatch), and workflow_dispatch is the documented exception that makes the re-dispatch land. api-ci-cd.yml gains a `deploy` input (default true) and the deploy gate becomes github.ref == 'refs/heads/main' || (github.event_name == 'workflow_dispatch' && inputs.deploy) Until now ANY manual dispatch deployed, so an automated checks-only rerun of a Dependabot branch would have shipped that branch to the App Service. Default true keeps the existing operator flow: Run workflow on main with the box ticked deploys exactly as before. Dependabot branches forked before this commit reject a deploy=false dispatch with 422 Unexpected inputs - a loud no-op rather than a deploy, gone as soon as branches re-fork off the updated base. Verified: both files parse; the gate expression is push-safe (inputs is empty on push events, so main still auto-deploys via the first clause). The full loop gets its first live test on the next grouped nuget PR; until then the workflow is also manually dispatchable against any branch. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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.
Dependabot regenerates
packages.lock.jsononly for the projects whose.csprojit edits. Every project consuming the bumped package transitively keeps its old lock file, and locked-mode restore fails the whole solution withNU1004— the PR is born red, and rebasing cannot help. Grouping (#126) turned five such PRs into one; this closes the loop on that one. It broke three workflows across two branches on 2026-08-17 alone, and the fix each time was the same mechanicaldotnet restore --force-evaluateby hand.What's added
dependabot-lockfix.yml— fires on any failed API / CodeQL / container run of adependabot/nuget/**branch, regenerates the lock files, pushes the fix to the branch, and re-dispatches every required check on the fixed commit. Zero secrets, zero PATs. The three GitHub platform constraints that dictate its shape are documented in the file:dependabot[bot]get read-only tokens →workflow_runis the one trigger that still gets write.GITHUB_TOKENpushes trigger no workflows → the fixed commit would sit checkless forever.workflow_dispatchis the documented exception to (2) → the last step re-dispatches all required checks, all of which already declare it.It lives on
mainonly becauseworkflow_runonly fires from the default branch's copy; it serves dapper-based Dependabot branches from here. Also manually dispatchable against any branch.api-ci-cd.yml— gains adeployinput (default true) and the deploy gate becomesUntil now any manual dispatch deployed, so an automated checks-only rerun of a Dependabot branch would have shipped that branch to the App Service. Default true keeps the operator flow identical: Run workflow on
mainwith the box ticked deploys exactly as before.Edge behavior
deployinput; adeploy=falsedispatch against them fails 422Unexpected inputs— a loud no-op rather than a deploy. Self-heals as branches re-fork off the updated base.Verification
Both files parse; the gate expression is push-safe (
inputsis empty on push events, somainstill auto-deploys via the first clause). The full loop gets its first live test on the next grouped nuget PR — until then the manual dispatch path covers any occurrence.🤖 Generated with Claude Code