From b4e97a207fd0c43e99cfb1b356f5b27c1cd47e21 Mon Sep 17 00:00:00 2001 From: Miki Date: Wed, 2 Nov 2022 16:24:38 -0700 Subject: [PATCH] Prevent backport workflow from running on umerged PRs Signed-off-by: Miki --- .github/workflows/backport.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 1d05b416930..cb2e3c3049c 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