Skip to content

ci: fully automate the proxy release → chart pin flow with a fine-grained PAT (open, keep current, auto-merge the pin PR; no human step) #727

Closed

Description

@bpalermo

Goal

Remove the one human step left by #703: after a proxy-release run, the pin PR is opened, kept current with main, and merged automatically once ci + proxy + proxy-pin are green. #724 stays as the audit thread. No classic PAT, no ruleset bypass, no repo-setting change.

Why a token at all

GITHUB_TOKEN can push a branch but a PR it opens gets no pull_request runs (recursion guard), so required checks never appear and the ruleset can never be satisfied. A PR opened with a user token gets CI. A fine-grained PAT is that user token with the smallest possible blast radius.

The token (owner creates it; nothing else can)

Settings → Developer settings → Fine-grained tokens:

  • Resource owner bpalermo, Repository access: Only select repositories → bpalermo/aether.
  • Repository permissions: Contents: Read and write (push the pin branch), Pull requests: Read and write (open, update-branch, enable auto-merge, close superseded). Metadata: Read is implied. Nothing else — no Workflows, no Administration, no Actions.
  • Expiration: the maximum allowed (1 year). Rotation is handled by the workflow (below), not by memory.
  • Store as the repo Actions secret RELEASE_PAT. Never printed; only ever passed as GH_TOKEN to gh.

What it cannot do: bypass main's ruleset (no bypass actors), merge anything that is not green, touch other repos, edit workflows.

Workflow changes

  1. proxy-release.yml / bump-chart (replaces the hand-off one-liner; keeps the step summary and the proxy releases pending chart pin #724 comment as the record):
    • push chore/proxy-image-bump-<short sha> with RELEASE_PAT (so the push is attributed to the owner, not the bot);
    • gh pr create with GH_TOKEN=RELEASE_PAT → CI runs;
    • gh pr merge --auto --squash → GitHub merges it the moment the required checks pass; the ruleset is still the gate;
    • close any OTHER open chore/proxy-image-bump-* PR (superseded release) and delete its branch;
    • fall back to today's hand-off block if RELEASE_PAT is unset or rejected (gh auth status check), so a missing/expired token degrades to proxy-release bump-chart rewrites tag: but the chart prefers digest: — automated proxy releases never change the deployed image #703's behaviour, never to a red run.
  2. main.yaml (main-post-merge, ci: validate main after every merge and require branches up to date before merging (#679) #685) — add a step, with RELEASE_PAT: for every open chore/proxy-image-bump-* PR that is BEHIND, run gh pr update-branch. Reason: the ruleset requires branches to be current, GitHub's auto-merge does NOT update a branch by itself, so a pin PR that goes stale (any other merge lands first) would wait forever. An update by the PAT re-triggers CI and auto-merge then fires. Guard: skip if the PR has a merge conflict (Chart.yaml version taken by another chart bump → comment on proxy releases pending chart pin #724 and leave it to a human; same conflict class as tonight's docs(proxy): counters transfer as deltas across hot restart, not absolutes (#708) #711/fix(ci): serialise publishes and give the aether chart a commit-pinned tag (#692) #713 re-bump).
  3. Token-expiry sentinel — a tiny step in both workflows: curl -sI -H "Authorization: Bearer $RELEASE_PAT" https://api.github.com/user | grep -i github-authentication-token-expiration, parse the date, and ::warning::/comment on proxy releases pending chart pin #724 when < 30 days remain, ::error:: (but still fall back to the manual hand-off, never fail the release) when expired. This is the rotation reminder; it lands in the run summary and the audit issue.
  4. publish.yaml unchanged — publish-main concurrency (publish: concurrent runs race on the same chart version tag — older build overwrote newer (77a7d45 over 95b158e), deploy silently lacked #689 #692) already serialises the chart pushes that auto-merged pin PRs will now produce back-to-back.

Guard rails that stay

  • Required checks unchanged: ci (incl. proxy-pin, chart-version-bump, envoy-api-parity), proxy.
  • Deploy stays manual (helm upgrade with the commit-suffixed tag + the appVersion assert). Automating the talos deploy is a separate decision (Flux HelmRelease for aether) — not in scope here.
  • The step summary and the proxy releases pending chart pin #724 comment stay, so the record is identical whether the PAT or a human finished the job.

Validation

Merge the workflow PR (it triggers proxy-release itself): expect a pin PR opened by the owner within ~15 min, CI green, auto-merged, #724 comment says "auto-merged as "; then land an unrelated PR while a second pin PR is open to prove the update-branch step. Then helm show chart --version <X.Y.Z>-<sha> to confirm the publish.

Equivalent without expiry

A GitHub App (private, installed on this repo, same two permissions, actions/create-github-app-token per run) does exactly this with no expiry and an org-owned identity. Same workflow steps; only the token source differs. Listed here so the choice is explicit; this issue takes the PAT route as asked.

Refs: #703, #724, #692, #685.

Activity

  1. bpalermo commented on Sep 6, 2026

    @bpalermo
    OwnerAuthor

    Addendum: scope the secret to main with an environment

    Do NOT store RELEASE_PAT as a repository secret (readable by any same-repo branch's workflow run). Instead:

    1. Settings → Environments → New environment release → Deployment branches and tags: Selected branches and tags → add main (use the explicit name pattern; the "Protected branches only" preset keys off legacy branch-protection rules, not rulesets). No required reviewers, no wait timer.
    2. Add RELEASE_PAT as an environment secret of release.
    3. proxy-release.yml bump-chart and the main.yaml update-branch job declare environment: release. Environment secrets are injected only into jobs that reference the environment, and GitHub refuses to start such a job from any ref other than main. Both consumers already run only on push: main, so nothing changes functionally; a pull_request run or a workflow edited on a branch can never read the token.

    Residual: a workflow change that reaches main via a green PR runs with the secret afterwards — inherent to any post-merge secret. Optional closer: a ruleset rule requiring code-owner review for .github/workflows/** (gates workflow edits only, never releases).

  2. bpalermo commented on Sep 6, 2026

    @bpalermo
    OwnerAuthor

    Landed and proven end to end (2026-09-06)

    #730 merged (d16de76) → its own proxy-release run (34035841252) went green in all four jobs and, in auto mode:

    Environment scoping held: the job ran under environment: release from main; the PR-branch runs of #730 itself never had the token (bump-chart does not run on pull_request). Sentinel: the API returned no expiration header for this token — it appears to have no expiry set, so the 30-day warning will not fire; rotation is a policy choice, not a deadline.

    Not yet exercised: the refresh-pin-prs update-branch path (needs main to move while a pin PR is open). It will get its first real test the next time a release lands while another PR merges; the DIRTY-conflict path likewise. Manual fallback path was exercised by #703's run yesterday.

    Deploy stays manual: talos-main is on rev205 (0.92.6-bcf2352); 0.92.7 pins a functionally identical proxy (workflow-only change) and will ride the next real deploy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions