Skip to content

feat(ci): open, refresh and auto-merge the proxy chart-pin PR (#727) - #730

Merged
bpalermo merged 2 commits into
mainfrom
feat/727-release-automation
Sep 6, 2026
Merged

bpalermo merged 2 commits into
mainfrom
feat/727-release-automation

Conversation

@bpalermo

@bpalermo bpalermo commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Closes #727. Removes the one human step #703 left: after a proxy release the pin
PR is now opened, kept current with main, and squash-merged the moment ci +
proxy + proxy-pin are green. No classic PAT, no ruleset bypass, no repository
setting change.

Two modes, decided per run

proxy-release / bump-chart gains a first step, Resolve release token,
that sets mode=auto|manual:

  • auto — RELEASE_PAT is present and both gh auth status and gh api user
    accept it. The chart-pin branch is pushed with that token, gh pr create opens
    the PR (a PR opened by a user token fires pull_request normally, so the
    required checks actually run) and gh pr merge --auto --squash hands the merge
    to GitHub. The main ruleset — no bypass actors — remains the only gate: this
    can merge nothing that is not green. Other open chore/proxy-image-bump-* PRs
    are closed with a "superseded by #N" comment and their branches deleted. proxy releases pending chart pin #724
    gets the record: PR, digest, chart version, auto-merge state, superseded PRs,
    run link and the token's remaining life.
  • manual — no token, an expired or rejected one, or a gh pr create that
    failed. Byte-for-byte today's behaviour: the branch is pushed with
    GITHUB_TOKEN and the run summary + proxy releases pending chart pin #724 comment carry the exact gh pr create
    one-liner, now with a | release token | row naming which of the three it was.
    A missing, expired or rejected token degrades the run — it never fails it.

The no-diff path (a re-run of an already-pinned sha) is unchanged, and so is
concurrency: proxy-release-main.

Environment scoping — why a PR-branch run can never read the token

RELEASE_PAT is an environment secret of release, whose deployment-branch
policy names main only (issue addendum), and both consumers declare
environment: release. GitHub injects environment secrets solely into jobs that
reference the environment and refuses to start such a job from any other ref — so
a pull_request run, or a run of either workflow as edited on a branch, gets an
empty secrets.RELEASE_PAT and takes the manual path. Concretely: this very PR
cannot read the token. The residual is the one inherent to any post-merge secret —
a workflow change that reaches main through a green PR runs with it afterwards.

Permissions stay tight: GITHUB_TOKEN keeps contents: write (the manual push)
and issues: write (the #724 record) and gains no pull-requests: write —
the PAT does the PR work. Conversely the PAT has no Issues permission, so every
#724 comment is posted with GITHUB_TOKEN; that is why refresh-pin-prs carries
issues: write alongside contents: read.

Expiry sentinel

curl -sSI -H "Authorization: Bearer $RELEASE_PAT" https://api.github.com/user,
read github-authentication-token-expiration, compute the days left:

state run annotation | release token | row on #724
> 30 days none expires in 362 days (2027-09-03)
< 30 days ::warning::RELEASE_PAT expires in 11 day(s) (2026-09-18) — rotate it (docs/runbook.md §7) **expires in 11 day(s)** (2026-09-18) — rotate the release environment secret (docs/runbook.md §7)
expired ::error::RELEASE_PAT expired on … — falling back to the manual hand-off + mode=manual RELEASE_PAT expired on 2026-09-03 — rotate the release environment secret
missing / rejected ::notice:: / ::warning:: + mode=manual no RELEASE_PAT in the release environment / RELEASE_PAT was rejected by the API

The token is never echoed and is ::add-mask::ed defensively on top of Actions'
own masking; a HEAD request never reflects the Authorization header back.

Keeping the pin PR mergeable

main.yaml gains refresh-pin-prs (environment: release, if: always(), no
needs, contents: read + issues: write). Auto-merge does not update a
stale branch and the ruleset requires branches to be current, so a pin PR that
goes BEHIND when anything else lands first would wait forever. For each open PR
whose head matches chore/proxy-image-bump-* and whose body carries the
Auto-generated by the proxy-release run marker (both guards required, so it can
only ever touch PRs the release flow produced):

  • BEHIND → gh pr update-branch — that is an ordinary synchronize from a user
    token, so ci + proxy re-run and auto-merge fires when they go green;
  • DIRTY → a one-time comment on proxy releases pending chart pin #724 naming the PR (deduped by a
    <!-- pin-conflict:N --> marker), left for a human — this is the
    charts/aether/Chart.yaml version-taken conflict class;
  • CLEAN / BLOCKED / anything else → nothing.

Validation

  • python3 -c 'import yaml,sys;yaml.safe_load(open(sys.argv[1]))' on both
    workflows;
  • actionlint 1.7.7 with shellcheck 0.10.0 — clean (the two SC2016 hits were
    jq string literals containing backticks; annotated # shellcheck disable);
  • make format-check — clean;
  • every branch of the new shell exercised locally against stubbed gh/curl:
    token missing / healthy / <30d / expired / rejected, the auto and manual PR
    bodies and proxy releases pending chart pin #724 comments rendered in full, and BEHIND / DIRTY / BLOCKED
    refresh including the conflict-comment dedupe.

No charts/ change here (the merge commit only carries main's own).

Note: bump-chart does not run on this PR — proxy-release triggers on
push-to-main under proxy/** / its own file only — so CI here validates syntax
and the other jobs. The functional proof is the post-merge run: merging this PR
edits .github/workflows/proxy-release.yml and therefore triggers
proxy-release
, which should publish the image and then auto-open and
auto-merge the first pin PR, with the record on #724.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 2 commits September 6, 2026 10:12
#703 left one human step per proxy release: `proxy-release` pushed
`chore/proxy-image-bump-<short sha>` and handed off a `gh pr create`
one-liner, because `GITHUB_TOKEN` cannot open a PR here and a PR it opened
would fire no `pull_request` events, so the `ci` + `proxy` checks the `main`
ruleset requires would never report.

Give the flow a user identity instead. `bump-chart` now declares
`environment: release` and resolves a mode per run:

* auto — `RELEASE_PAT` (fine-grained, this repo only, Contents RW + Pull
  requests RW) is present and the API accepts it. The branch is pushed with
  that token, `gh pr create` opens the PR (a user token's PR gets ordinary
  checks) and `gh pr merge --auto --squash` hands the merge to GitHub. The
  ruleset stays the only gate — nothing merges that is not green. Superseded
  `chore/proxy-image-bump-*` PRs are closed and their branches deleted, and
  #724 records the PR, the digest, the chart version and the token's
  remaining life.
* manual — no token, an expired or rejected one, or a `gh pr create` that
  failed: byte-for-byte #703's hand-off, summary and #724 comment included,
  plus a row naming which of the three it was. A dead token degrades a
  release, it never fails one.

A token-expiry sentinel reads `github-authentication-token-expiration` off
`api.github.com/user`, warns under 30 days and forces manual mode once past
the date; the token itself is never echoed and is re-masked defensively.

`main-post-merge` gains `refresh-pin-prs`: auto-merge does not update a
stale branch and the ruleset requires branches to be current, so a pin PR
that goes `BEHIND` when anything else lands first would wait forever. The
job runs `gh pr update-branch` on `BEHIND` pin PRs (which re-triggers CI, so
auto-merge fires when it goes green), records `DIRTY` ones on #724 once and
leaves them to a human, and touches nothing else. Both guards are required
before it acts: the `chore/proxy-image-bump-*` head branch AND the
`Auto-generated by the proxy-release run` body marker.

`RELEASE_PAT` is an environment secret of `release` (deployment branches:
`main` only), so a `pull_request` run — or a run of either workflow as
edited on a branch — can never read it. GITHUB_TOKEN gains no
`pull-requests: write`; it keeps `contents: write` for the manual push and
`issues: write` for the #724 record, which the PAT deliberately cannot post.

docs/runbook.md §7 documents both modes and the rotation procedure.

Validated: `yaml.safe_load` on both workflows, `actionlint 1.7.7` with
shellcheck 0.10.0 (clean), `make format-check`, and every branch of the new
shell (token missing/healthy/near-expiry/expired/rejected, auto and manual
PR bodies, BEHIND/DIRTY/CLEAN refresh, conflict-comment dedupe) exercised
locally against stubbed `gh`/`curl`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit d16de76 into main Sep 6, 2026
18 checks passed
@bpalermo
bpalermo deleted the feat/727-release-automation branch September 6, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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)

1 participant