From 4317f47fcac805f7f14a82a36832d2f433d7dfc8 Mon Sep 17 00:00:00 2001 From: Jeri Peier Date: Mon, 28 Oct 2024 16:29:10 +0100 Subject: [PATCH] build: filter labels before cherry picking (#3185) (cherry picked from commit 772e8992ac97ec21449197931c398d0f3a7ba2b5) --- .github/workflows/maintenance-cherry-pick.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maintenance-cherry-pick.yml b/.github/workflows/maintenance-cherry-pick.yml index f7536dec22..f95f2f586d 100644 --- a/.github/workflows/maintenance-cherry-pick.yml +++ b/.github/workflows/maintenance-cherry-pick.yml @@ -20,16 +20,28 @@ jobs: steps: - run: echo Labels are not empty, continuing - cherry_pick: + filter_labels: needs: [check_labels] runs-on: ubuntu-latest + outputs: + filtered_labels: ${{ steps.filter.outputs.filtered_labels }} + steps: + - name: Filter labels + id: filter + run: | + FILTERED_LABELS=$(jq -r '.pull_request.labels | map(select(.name | test("^target: [0-9]+\\.x$"))) | .[].name' <<< "${{ toJSON(github.event) }}") + echo "filtered_labels=${FILTERED_LABELS}" >> $GITHUB_OUTPUT + + cherry_pick: + needs: [filter_labels] + runs-on: ubuntu-latest if: github.event.pull_request.merged == true && github.event.pull_request.user.login != 'renovate[bot]' outputs: failed_branches: ${{ steps.update_failed_branches.outputs.failed_branches }} strategy: matrix: - label: ${{ github.event.pull_request.labels.*.name }} + label: ${{ fromJson(needs.filter_labels.outputs.filtered_labels) }} steps: - name: Get token @@ -49,7 +61,7 @@ jobs: token: ${{ steps.get_token.outputs.token }} fetch-depth: 0 - - name: Cherry-pick changes into ${{ steps.branch_name.outputs.branch }} + - name: Cherry-pick changes into ${{ steps.branch_name.outputs.branch }} if: steps.branch_name.outputs.branch run: | git checkout ${{ steps.branch_name.outputs.branch }}