Skip to content

feat(link-backport-prs): link backport PRs to matching Linear sub-issue#157

Merged
Piotr1215 merged 3 commits into
mainfrom
devops-693/patch-backport-automation
Jul 3, 2026
Merged

feat(link-backport-prs): link backport PRs to matching Linear sub-issue#157
Piotr1215 merged 3 commits into
mainfrom
devops-693/patch-backport-automation

Conversation

@Piotr1215

Copy link
Copy Markdown
Contributor

Summary

Backport PRs opened by sorenlouv were never connected to the per-release-line Linear sub-issues ([0.34] Copy of ENG-x) that track each maintenance line. Those sub-issues stayed open after their backport merged, so patch-release tracking drifted and had to be reconciled by hand.

This adds a link-backport-prs composite action and wires it into the shared backport.yaml reusable workflow. After the backports are created, it links each one to the matching Linear sub-issue by adding Fixes <id> to the backport PR body, so the right sub-issue closes when the backport merges.

This implements the linking step described in Denise's comment on DEVOPS-693 (the authoritative spec) and step 6.1 of the "WIP: Patch Issue Management" Notion doc.

How it works

The trigger is the GitHub side, not Linear: the backport PR only exists after the source PR merges and sorenlouv runs, which a Linear webhook never sees. So the step runs inside backport.yaml, in the same job that creates the PRs. For each backport-to-vX.Y label on the merged source PR:

  1. Resolve the source PR's Linear issue (the parent) via Linear attachmentsForURL, falling back to a TEAM-123 identifier parsed from the branch or body.
  2. Reconstruct the backport PR sorenlouv created (head: backport/vX.Y/pr-<src>, base: vX.Y).
  3. Find the sub-issue under the parent whose title carries the release-line prefix ([0.34] or [v0.34]).
  4. Append Fixes <sub-issue-id> to that backport PR's body, unless it already references the issue.

Matching is by title prefix, not milestone: the backport-copy sub-issues do not reliably carry a patch milestone and can live in the parent's project, so the title is the dependable key. Verified end to end against a real family: vcluster#3993 -> parent ENGCP-906 -> ENGCP-913 [0.34] and ENGCP-943 [0.35].

Key Changes

  • New .github/actions/link-backport-prs Go composite action (modeled on linear-pr-commenter), with unit tests for the matching logic.
  • backport.yaml: optional linear-token secret and an advisory step that runs the action after sorenlouv.
  • Makefile target test-link-backport-prs, CI workflow test-link-backport-prs.yaml, README entry, and regenerated docs/workflows/backport.md.

Backward compatibility

Strictly additive. The linear-token secret is optional, the step is continue-on-error: true, and the action exits 0 and no-ops when no token is provided. Existing callers (e.g. vcluster on @backport/v1) are unaffected until the coordination tag is moved.

Notes / dependencies

  • This is the linking half. It only links sub-issues that already exist. Those [X.Y] Copy of ... sub-issues are meant to be created by the linear-webhook-service needs-backport automation; that automation requires the issue to have a milestone and be in a patch-release project, and currently the copies are often created by hand. The linker works regardless of who created them, but its end-to-end value depends on the copies existing.
  • Resolving the parent uses Linear attachmentsForURL; if Linear's schema differs in practice this is the first thing to validate against a live token.

TODO before this takes effect in production

  • Push the action tag link-backport-prs/v1 and move the backport/v1 coordination tag to this commit (the workflow references the action by @link-backport-prs/v1, following the notify-release / release-notification pattern).
  • Have callers (vcluster, vcluster-pro, loft-enterprise) pass linear-token: ${{ secrets.LINEAR_API_TOKEN }} to enable linking.

Closes DEVOPS-693

@Piotr1215 Piotr1215 requested a review from sydorovdmytro June 22, 2026 07:54
Comment thread .github/actions/link-backport-prs/src/go.mod Outdated
Comment thread .github/actions/link-backport-prs/src/go.mod Outdated
Comment thread .github/actions/link-backport-prs/action.yml
Piotr1215 added a commit that referenced this pull request Jul 2, 2026
Review feedback on #157 flagged that the action's go.mod pinned an
outdated Go (1.25.0) and go-github (v84) while newer releases are out.

go-github v88 redesigned the client constructor: NewClient now returns
(*Client, error) and takes functional options instead of an *http.Client.
Switched to github.WithAuthToken, which authenticates directly and lets
us drop the golang.org/x/oauth2 dependency entirely.

Added a renovate gomod group rule for link-backport-prs so its Go
toolchain and go-github version track upstream automatically, matching
the existing linear-pr-commenter and linear-release-sync rules.
@Piotr1215 Piotr1215 force-pushed the devops-693/patch-backport-automation branch from 7b8ac9b to d92e8c6 Compare July 2, 2026 08:54
@Piotr1215 Piotr1215 requested a review from sydorovdmytro July 2, 2026 08:57
Piotr1215 added 3 commits July 3, 2026 15:47
Backport PRs opened by sorenlouv were not connected to the per-release-line
Linear sub-issues ("[0.34] Copy of ENG-x") that track each maintenance line.
The sub-issues stayed open after their backport merged, so patch-release
tracking drifted and had to be reconciled by hand (the Maintenance project
checklist in Notion).

This adds a step to the shared backport workflow that runs after the backports
are created and, for each backport target, resolves the source PR's Linear
issue (the parent) via attachmentsForURL, finds the sub-issue whose title
carries the release-line prefix, and appends "Fixes <id>" to that backport PR
so the right sub-issue closes on merge.

Matching is by title prefix ("[0.34]" / "[v0.34]"), not milestone: the
backport-copy sub-issues do not reliably carry a patch milestone and may live
in the parent's project, so the title is the dependable key (verified against
ENGCP-906 -> ENGCP-913/ENGCP-943).

The step is advisory and backward compatible: the new linear-token secret is
optional, the step is continue-on-error, and the action exits 0 (and no-ops
without a token), so existing backport callers are unaffected.

Closes DEVOPS-693
Review feedback on #157 flagged that the action's go.mod pinned an
outdated Go (1.25.0) and go-github (v84) while newer releases are out.

go-github v88 redesigned the client constructor: NewClient now returns
(*Client, error) and takes functional options instead of an *http.Client.
Switched to github.WithAuthToken, which authenticates directly and lets
us drop the golang.org/x/oauth2 dependency entirely.

Added a renovate gomod group rule for link-backport-prs so its Go
toolchain and go-github version track upstream automatically, matching
the existing linear-pr-commenter and linear-release-sync rules.
A reviewer read the optional linear-token as an oversight and expected
it to be required. It is optional on purpose: the linking step is
advisory and no-ops when the token is absent so callers can adopt the
shared backport workflow before wiring up a Linear token. Spell that
out in the input description so the next reader does not have to ask.
@Piotr1215 Piotr1215 force-pushed the devops-693/patch-backport-automation branch from d92e8c6 to c3e8c3b Compare July 3, 2026 13:47
@Piotr1215 Piotr1215 merged commit 2de17e8 into main Jul 3, 2026
9 checks passed
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.

2 participants