Skip to content

Commit 715ff72

Browse files
authored
Add condition that PRs are merged in backport workflow (#5997)
This brings our backport workflow script in line with the script from the [tibdex/backport][1] github action implementation. [1]: https://github.com/tibdex/backport/blob/b1bb2aaf611d9f2e5d1900c06493769b9f102a45/.github/workflows/backport.yml#L12-L22 Signed-off-by: Andrew Ross <andrross@amazon.com>
1 parent 97c5978 commit 715ff72

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

.github/workflows/backport.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,22 @@ on:
77

88
jobs:
99
backport:
10-
if: ${{ contains(github.event.label.name, 'backport') }}
10+
name: Backport
1111
runs-on: ubuntu-latest
12+
# Only react to merged PRs for security reasons.
13+
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
14+
if: >
15+
github.event.pull_request.merged
16+
&& (
17+
github.event.action == 'closed'
18+
|| (
19+
github.event.action == 'labeled'
20+
&& contains(github.event.label.name, 'backport')
21+
)
22+
)
1223
permissions:
1324
contents: write
1425
pull-requests: write
15-
name: Backport
1626
steps:
1727
- name: GitHub App token
1828
id: github_app_token

0 commit comments

Comments
 (0)