Chore(ci): add a backport workflow (labels and /backport)

Merged
JE
18h ago
+145-0

Description

Adds .github/workflows/backport.yml, so a fix merged to master can be backported to the release
branches by a label or a comment instead of by hand (the release-branch fixes so far, e.g. #187, were
cherry-picked manually):

  • merge a PR into master with the backport release-1.9 / backport release-1.10 labels → one backport
    PR per label;
  • comment /backport release-1.9 (or /backport 1.9; several branches separated by spaces) on a merged
    PR → backport PRs for those branches. Only people with write access can do this. Use it also when the
    label was forgotten at the merge: adding a label afterwards does nothing.

The file is the same as oam-dev/docker-terraform#30, which has been opening that repo's backports since
2026-11-19.

Why not pull_request_target. GitHub blocks pull_request_target by default in public repositories
from 2026-12-02
.
So the labels are read on the push of the merge commit to master: the workflow looks up the PR merged
as that commit and its backport labels; a push that isn't a merged PR, or a PR without such a label,
ends there (green, nothing else runs). master is protected, so each push is one merged PR. /backport
runs on issue_comment, which isn't affected.

It uses korthout/backport-action v4.7.0 (the action
kubevela uses), pinned by SHA. Commits are cherry-picked with -x and keep their author and
Signed-off-by; the backport PR is titled [Backport release-x.y] <title>. If a cherry-pick conflicts,
the action comments on the original PR with the commands to do it by hand, and the run fails so it shows
in Actions.

GitHub App token. With the repository variable BACKPORT_APP_CLIENT_ID and the secret
BACKPORT_APP_PRIVATE_KEY set (as they now are here), the PRs are opened with the app's token, so CI runs
on them as on any PR. Without them the workflow falls back to GITHUB_TOKEN, which needs the repository
setting "Allow GitHub Actions to create and approve pull requests", and the PRs' checks wait for a
maintainer to approve them.

Security: push runs only what is already merged into master, and issue_comment runs this file
from master; the checkout is master, nothing from the PR is built or executed, the commits are only
cherry-picked. Labels, comment and actor reach the shell only as environment variables.

I have:

  • Signed off the commits (DCO).
  • Run actionlint (with shellcheck) on the workflow.
  • Run it on my fork (below).

How has this been tested

On my fork, with release-1.9, release-1.10 and the two labels set up as here (the fork has no app, so
with GITHUB_TOKEN):

CaseResult
merging this workflow (no labels)run green, "has no backport label; nothing to backport"
a PR with both labels merged[Backport release-1.9] … and [Backport release-1.10] … opened, one commit each with (cherry picked from commit …) and the Signed-off-by; a comment on the original PR listing both
/backport release-1.9 on a merged PR without labels[Backport release-1.9] … opened, the same way; a comment on the original PR

With the app token set here, the backport PRs' CI should start on its own, as on docker-terraform.

Once merged, the first labelled merge (the RELEASE.md PR that follows) will be its first real run.


Summary by cubic

Adds a backport workflow so fixes merged to master can be backported to release branches by label or comment instead of manual cherry-picks.

  • Merging a PR with backport release-1.9 / backport release-1.10 labels opens one backport PR per label.
  • Commenting /backport release-1.9 (or /backport 1.9, several branches separated by spaces) on a merged PR opens backport PRs; write access is required.
  • /backport also covers labels forgotten at merge time; adding the label afterwards does nothing.
  • Runs on push to master rather than pull_request_target, which GitHub blocks by default in public repositories from 2026-12-02.
  • Uses korthout/backport-action v4.7.0 pinned by SHA; commits keep their author and Signed-off-by, and conflicts are reported on the original PR with the run failing.
  • Backport PRs open with a GitHub App token when BACKPORT_APP_CLIENT_ID and BACKPORT_APP_PRIVATE_KEY are set; otherwise they fall back to GITHUB_TOKEN, need the "Allow GitHub Actions to create and approve pull requests" setting, and wait for a maintainer to approve.