Skip to content

Commit af317f1

Browse files
fix(ci): stop backport workflow from cascading on its own PRs
Two compounding issues caused merging a backport PR to spawn another backport (e.g. #2581 [Backport release-1.2] [Backport release-1.3] ... from #2579): 1. pr-labeler auto-added the `backport` label to any PR whose title started with `[Backport release-X.Y]` (regression introduced in c8ed1c6 when pr-labeler.yaml was first added). korthout/backport- action puts that prefix on every backport PR it creates, so the label was being re-applied to every backport, satisfying the workflow's gate when the backport itself was merged. 2. Even with that fixed, an external labeling bot (dosubot) still re-applies `backport-previous` to backport PRs based on similarity to the parent. That bot is configured at the org level and cannot be controlled from this repo. Drop the `toAdd.add('backport')` line from pr-labeler so the label isn't propagated by us, and gate both backport jobs on `pull_request.base.ref == 'main'` so backport PRs (which target release-X.Y) cannot trigger the workflow regardless of what labels end up on them. Assisted-By: Claude <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent 7520967 commit af317f1

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

‎.github/workflows/backport.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
prepare:
1818
if: |
1919
github.event.pull_request.merged == true &&
20+
github.event.pull_request.base.ref == 'main' &&
2021
(
2122
contains(github.event.pull_request.labels.*.name, 'backport') ||
2223
contains(github.event.pull_request.labels.*.name, 'backport-previous') ||
@@ -90,6 +91,7 @@ jobs:
9091
needs: prepare
9192
if: |
9293
github.event.pull_request.merged == true &&
94+
github.event.pull_request.base.ref == 'main' &&
9395
(needs.prepare.outputs.backport_current == 'true' || needs.prepare.outputs.backport_previous == 'true')
9496
runs-on: [self-hosted]
9597
strategy:

‎.github/workflows/pr-labeler.yaml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ jobs:
134134
const cleanTitle = backportMatch ? backportMatch[2] : title;
135135
if (backportMatch) {
136136
toAdd.add('area/release');
137-
toAdd.add('backport');
138137
}
139138
140139
// 2. Try Conventional Commits form: type(scope)?(!)?: description

0 commit comments

Comments
 (0)