Skip to content

Commit 09a663b

Browse files
committed
Fix broken job by allowing "unsafe checkout". Add comment to describe why. Also tweak the run statement to only trigger job if a "port to" label exists.
1 parent 082924c commit 09a663b

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

.github/workflows/port_merged_pull_request.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,21 @@ permissions:
1919
jobs:
2020
port_pr:
2121
runs-on: ubuntu-slim
22-
# Don't run on closed *unmerged* pull requests
23-
if: github.event.pull_request.merged
22+
# Only run on MERGED pull requests,
23+
# and only run if the merged PR has a label that starts with "port to"
24+
if: >
25+
github.event.pull_request.merged &&
26+
contains(toJSON(github.event.pull_request.labels.*.name), '"port to ')
2427
steps:
2528
# Checkout code
2629
- uses: actions/checkout@v7
30+
with:
31+
# When using 'pull_request_target' (see above), this 'checkout' step will always fail because it
32+
# may make the codebase vulnerable to "pwn requests" via the user-created PR.
33+
# See https://docs.github.com/en/actions/reference/security/securely-using-pull_request_target
34+
# However, we are allowing this unsafe checkout because (1) it's required to backport the PR, and
35+
# (2) this job only runs when a PR is MERGED, and merger only happens after a thorough review of the PR.
36+
allow-unsafe-pr-checkout: true
2737
# Port PR to other branch (ONLY if labeled with "port to")
2838
# See https://github.com/korthout/backport-action
2939
- name: Create backport pull requests

0 commit comments

Comments
 (0)