Skip to content

fix: write finalize state through GitHub API to satisfy protected trunk - #94

Merged
joshua-temple merged 1 commit into
mainfrom
fix/finalize-state-commit
Jun 10, 2026
Merged

joshua-temple merged 1 commit into
mainfrom
fix/finalize-state-commit

Conversation

@joshua-temple

Copy link
Copy Markdown
Collaborator

Fixes the Orchestrate "Finalize" job, which fails now that main is protected: it pushes the chore: update state [skip ci] commit with git push origin main, and branch protection rejects the direct push (GH006: Required status check "PR Gate" is expected). The same bot commits were also unsigned.

On real GitHub the state write now goes through the Contents REST API (gh api -X PUT repos/{repo}/contents/<manifest>). API commits are signed by GitHub (Verified) and, with a bypass-capable token, update the protected trunk without satisfying the PR gate. The act/gitea e2e environment keeps the existing git push path, detected via GITHUB_SERVER_URL, so the harness is unchanged.

  • Orchestrate, release, and promote finalize steps all route through a shared emitter (state_write.go) and the CLI's Finalizer.CommitAndPush, which branch on real-GitHub vs gitea.
  • New optional state_token manifest field (default ${{ secrets.GITHUB_TOKEN }}), emitted as GH_TOKEN, so the token used for the API write is configurable. Point it at a bypass-capable App or PAT secret to activate the protected-trunk write. Existing manifests are unaffected.
  • Both API and git paths retry with fetch/reset/reapply to tolerate concurrent runs.

Verification: go build ./... clean, go test ./internal/... green (1008), go vet and golangci-lint clean, generated workflows contain zero em dashes, and the multistep e2e (TestMultiStepScenarios) passes under act, confirming the gitea path is preserved.

Note: until the state_token is pointed at a bypass-capable token, the default GITHUB_TOKEN cannot update the protected branch, so this PR puts the mechanism in place but the trunk write activates once that secret is configured.

The generated finalize jobs persisted manifest state with git push to the
trunk branch. With branch protection requiring a status check, that push is
rejected, and the bot commits are unsigned. On real GitHub the orchestrate,
release, and promote finalize paths now write the manifest through the
Contents REST API, which produces a verified, signed commit and, with a
bypass-capable token, updates a protected trunk. The act/gitea e2e path keeps
the existing git push. A new optional state_token config (default
GITHUB_TOKEN) supplies the API token.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple
joshua-temple force-pushed the fix/finalize-state-commit branch from d04d8f3 to 37d3252 Compare June 10, 2026 13:56
@joshua-temple
joshua-temple merged commit 4710daf into main Jun 10, 2026
6 checks passed
@joshua-temple
joshua-temple deleted the fix/finalize-state-commit branch June 10, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant