From c26cdf8da6878eef0effebd826d7067b985524b5 Mon Sep 17 00:00:00 2001 From: Miki Date: Wed, 2 Nov 2022 20:21:26 -0700 Subject: [PATCH] Prevent backport workflow from running on umerged PRs (#2746) Signed-off-by: Miki Signed-off-by: Miki Signed-off-by: David Sinclair --- .github/workflows/backport.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 1d05b4169306..cb2e3c3049c6 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -12,6 +12,17 @@ jobs: contents: write pull-requests: write name: Backport + # Only react to merged PRs for security reasons. + # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target. + if: > + github.event.pull_request.merged + && ( + github.event.action == 'closed' + || ( + github.event.action == 'labeled' + && contains(github.event.label.name, 'backport') + ) + ) steps: - name: GitHub App token id: github_app_token