From 243e617ff277d66705d95a20e523c9428508728f Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 6 Nov 2026 13:35:56 +0100 Subject: [PATCH] Now removes the cherry-pick? label after successful backports Ticket: ENT-14717 Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lars Erik Wik --- .github/workflows/job-backport.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/job-backport.yml b/.github/workflows/job-backport.yml index b430c7b5816..e93108a2bc5 100644 --- a/.github/workflows/job-backport.yml +++ b/.github/workflows/job-backport.yml @@ -3,7 +3,8 @@ name: Backport # Opens backport pull requests to the LTS branches when a pull request with the # `cherry-pick?` label is merged to master. Commits are cherry-picked with `-x`. # Each branch comments on the original pull request with the backport link, or -# says that a manual backport is needed. +# says that a manual backport is needed. If all branches succeed, the label is +# removed. # # The label must be set before merging. # @@ -94,4 +95,24 @@ jobs: gh pr comment "$PR" --body "Backport to $BRANCH: $URL" else gh pr comment "$PR" --body "Backport to $BRANCH failed, manual backport needed: $RUN_URL" + # Fail the job so the label is kept + exit 1 + fi + + remove_label: + needs: backport + runs-on: ubuntu-latest + steps: + - name: Remove the label + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + MERGE_SHA: ${{ github.sha }} + run: | + pr=$(gh api "repos/$GH_REPO/commits/$MERGE_SHA/pulls" \ + --jq 'first(.[] | select(any(.labels[]; .name == "cherry-pick?")) | .number)') + if [ -z "$pr" ]; then + echo "No merged PR with the cherry-pick? label, nothing to do" + exit 0 fi + gh pr edit "$pr" --remove-label "cherry-pick?"