From 8bdff0d6814c23940dc1f698f91c9d7ef59f9cad Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Fri, 9 Aug 2024 09:56:02 +0200 Subject: [PATCH] fix(backport): Workaround not to fail if no backport is needed (#4707) --- .github/workflows/backport.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 4e58479c84..c111897b80 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -11,16 +11,28 @@ jobs: if: github.event.pull_request.merged == true && !(contains(github.event.pull_request.labels.*.name, 'backport')) runs-on: ubuntu-latest steps: + # Workaround not to fail the workflow if the PR does not need a backport + # https://github.com/sorenlouv/backport-github-action/issues/127#issuecomment-2258561266 + - name: Check for backport labels + id: check_labels + run: |- + labels='${{ toJSON(github.event.pull_request.labels.*.name) }}' + echo "$labels" + matched=$(echo "${labels}" | jq '. | map(select(startswith("backport-to-"))) | length') + echo "matched=$matched" + echo "matched=$matched" >> $GITHUB_OUTPUT + - name: Backport Action + if: fromJSON(steps.check_labels.outputs.matched) > 0 uses: sorenlouv/backport-github-action@v9.5.1 with: github_token: ${{ secrets.GITHUB_TOKEN }} auto_backport_label_prefix: backport-to- - name: Info log - if: ${{ success() }} + if: ${{ success() && fromJSON(steps.check_labels.outputs.matched) > 0 }} run: cat ~/.backport/backport.info.log - name: Debug log - if: ${{ failure() }} + if: ${{ failure() && fromJSON(steps.check_labels.outputs.matched) > 0 }} run: cat ~/.backport/backport.debug.log