Repository navigation
feat(go-generated): push the regenerated code on Renovate branches (MK8S-516) - #117
Merged
ezekiel-alexrod merged 9 commits intoNov 19, 2026
Merged
Conversation
|
ezekiel-alexrod
force-pushed
the
improvement/MK8S-516-go-generated-renovate-push
branch
from
November 18, 2026 10:35
68d0538 to
99274d4
Compare
|
When Renovate bumps a code generator, its PR changes go.mod but not the generated code, and the check fails until someone pushes the fix on the Renovate branch. Renovate then stops updating that branch. With push-to-renovate-branches, the workflow pushes the regenerated code itself. The commands still run with a read-only token; a second job, on a fresh GitHub-hosted runner and without running the repository code, applies the result and pushes it with an App token limited to the repository, so the required checks run again on the new commit. It only pushes changes under working-directory, never under .github/, stops when files it already regenerated still differ, and does not force-push. Refs: MK8S-516
… push The input check failed every PR that gets no Actions secrets, such as Dependabot and fork PRs. It now fails only when a push is due, and warns otherwise. The outside-working-directory check ran in the job that runs the generators, so a compromised generator could fake it. The push job now checks again that every path of the patch is under working-directory. Refs: MK8S-516
ezekiel-alexrod
force-pushed
the
improvement/MK8S-516-go-generated-renovate-push
branch
from
November 18, 2026 10:42
99274d4 to
4409b4a
Compare
|
The input check read secrets.ACTIONS_APP_PRIVATE_KEY in the job that runs the generators, so the key reached that runner. It now runs in a job of its own, with no checkout; RENOVATE_PUSH moves to the workflow env so both jobs share it. The .github/ guard piped git diff into grep -q under pipefail: an early grep exit could kill git diff and hide the match. Read the names into a variable first, as for the loop guard. Refs: MK8S-516
|
This was referenced Nov 18, 2026
The push job ran on the patch output alone, which comes from the job that runs the generators. A generator can write RENOVATE_PUSH=true to $GITHUB_ENV there, so a patch could be pushed to a branch that is not a Renovate one. The job-level if now checks the branch and the repository itself. Refs: MK8S-516
|
secrets: inherit also hands GIT_ACCESS_TOKEN to the job that runs the generators, and that org token may not be read-only. Refs: MK8S-516
|
|
With one call per module, parallel push jobs can all pass the old ls-remote check, and the losing push failed red. Push first, and only when it is rejected check whether the branch moved. Refs: MK8S-516
|
LGTM |
Refs: MK8S-516
|
No caller uses it, and every job now runs on ubuntu-26.04. Refs: MK8S-516
|
TeddyAndrieux
approved these changes
Nov 19, 2026
ezekiel-alexrod
deleted the
improvement/MK8S-516-go-generated-renovate-push
branch
November 19, 2026 16:14
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.
This adds a
push-to-renovate-branchesmode to thego-generatedworkflow of #115: on a Renovate branch, the workflow pushes the regenerated code itself, so a generator bump no longer needs a human commit.Stacked on #115: the base of this PR becomes
mainonce #115 is merged.Problem
When Renovate bumps a code generator (oapi-codegen, mockery, controller-tools), its PR only changes
go.modandgo.sum. The generated code is not touched, so the repo's generated-files check fails until someone runs the generator and pushes on the Renovate branch. Renovate then sees a commit it did not make, and stops updating that branch (rebases, new versions). Examples: scality/metalk8s-registry-node-agent#203 (oapi-codegen, regenerated by hand on 2026-10-30), scality/platform-uploads-api#96 (red today for this reason).Renovate can run
go generateitself (postUpdateOptions: ["goGenerate"]), but not safely in our setup: it runs every Go command of that step withGIT_CONFIG_*variables that hold the bot's GitHub token, so a bumped generator could read the token of the Renovate App, which can write to all our repos. That was the plan of scality/platform-renovate#62 and scality/devinfra#807, found by their review. Regenerating in CI instead keeps the generator away from any write token.What changes
push-to-renovate-branches(defaultfalse) andactions-app-id, new optional secretACTIONS_APP_PRIVATE_KEY. Nothing changes for current callers.renovate/*branch of the repo (never a fork), thego-generatedjob runs the commands on the branch head with a read-only token, and uploads the diff ofworking-directoryas an artifact. The check still fails on that commit.GITHUB_TOKENstarts no workflow, so the required checks would never run on the new commit.working-directoryor under.github/(moves included), when files the App already regenerated on the branch still differ (no loop, also with one call per module), or when Renovate moved the branch meanwhile. The push job checks the paths again, since the first job ran the generators. No force-push.validate-push-inputsjob, with no checkout, checks the App config. It fails only when a push is due, and warns otherwise, so Dependabot and fork PRs, which get no Actions secrets, stay green. The App key never reaches the job that runs the generators.docs/go-generated.mdexplains the mode, its guards and its limits.tests.yamlruns the existing call with the mode on.Review guide
The
push-to-renovate-branchjob is the part to read, then theSave the regenerated codestep. Feedback welcome on the guards, and on the security trade-off in Known limits.Testing
actionlintongo-generated.yamlandtests.yamlmkdocs build --strict.github/guard, local git repo:pkg/gen.go,.github/ö.yml,.github/ci.yml, move of.github/workflows/ci.yamltox/working-directory: svc: change insvc/, in../go.work.sum, new file at the root; andworking-directory: .scality/workflowsreadsvars.ACTIONS_APP_IDand theACTIONS_APP_PRIVATE_KEYorg secretgitIgnoredAuthorsKnown limits
gitIgnoredAuthorsin scality/platform-renovate, or Renovate stops updating the branch after the first push.Out of scope
gitIgnoredAuthorsentry: separate PRs (MK8S-516).Refs: MK8S-516