Files
coder/.github/workflows
Denis AfonsoandClaude Opus 5.5 34c8bda1a8 ci: use backport app token in cherry-pick workflow (#32803)
The cherry-pick workflow can no longer open PRs. Since
coder/github-org-terraform#76 (Nov 17), the org disables "Allow GitHub
Actions to create and approve pull requests", so `gh pr create` with
`GITHUB_TOKEN` fails:

```
GraphQL: GitHub Actions is not permitted to create or approve pull requests (createPullRequest)
```

Example: [run
45991857596](https://github.com/coder/coder/actions/runs/45991857596/job/140481380335)
for #32793. That run had already pushed `backport/32793-to-<version>`,
and because the workflow exits as soon as the branch exists, re-running
it can't open the PR.

`backport.yaml` already opens its PRs with the backporter App token
(#32352). This brings `cherry-pick.yaml` in line with it.

**App token**

- Runs the job in `environment: main` with only `contents: read` and
`id-token: write` for the job token.
- Mints the token with the same pinned `coder/github-app-token-action`
step and `BACKPORT_APP_*` inputs (contents, pull_requests, workflows and
issues write on coder/coder).
- Uses the App token for both `git push` and `gh`, and commits as the
App bot, as backport does.

**Recovery on re-runs, as in `backport.yaml`**

- Checks for an existing PR first (`--state all`) and exits only if
there is one.
- If the branch already exists, reuses it and goes on to open the PR. If
its tip is the conflict placeholder commit, the PR keeps the `
(conflicts)` title suffix.
- Otherwise cherry-picks and pushes as before.

**Best-effort extras, as in `backport.yaml`**

- `gh pr create` only sets base, head, title and body. Label, assignee
and reviewer are added afterwards with separate `gh pr edit` calls that
warn instead of failing.
- `gh label create` warns instead of failing.

Branch naming, the conflict placeholder, the PR body and the comment on
the original PR are unchanged.

**Side effects**

- Cherry-pick PRs are now opened by the App, not `github-actions[bot]`,
so they trigger CI like any other PR.
- They also trigger `pr-cherry-pick-check.yaml`, which comments when a
title doesn't start with `fix:`. Conflicts are therefore marked with a `
(conflicts)` suffix, as in `backport.yaml`, instead of a `[CONFLICT]`
prefix.
- With `workflows: write`, cherry-picks that touch `.github/workflows/`
can now be pushed too.
- Approvals: the requester is still asked to review the cherry-pick, so
they can approve and merge their own cherry-pick. That isn't new, and
backport works the same way. The proposal to require a
`release-managers` approval on bot-opened release PRs isn't in
`coder.yaml` yet
([discussion](https://codercom.slack.com/archives/C0CHP8J479T/p1795510371505229)).

> [!IMPORTANT]
> The backporter App's Cloud KMS key only signs for
`/.github/workflows/backport.yaml@refs/heads/main`
(`coder-backporter-app` in coder/gcp
`projects/production/coder-github-apps/apps.tf`). coder/gcp#497 adds
`/.github/workflows/cherry-pick.yaml@refs/heads/main`; merge and apply
it first, or the token step fails to sign.

Validated with `actionlint` (with shellcheck) and `zizmor --offline` (no
findings). I also ran the script locally with a stubbed `gh` against a
local remote: existing PR → skip; fresh run → PR opened, failing
label/reviewer calls only warn; stranded placeholder branch → reused and
opened with the ` (conflicts)` suffix.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 17:14:06 +00:00
..
2026-11-04 15:47:27 -06:00