Skip to content

Commit 648a1ae

Browse files
authored
fix(zizmor): support pull_request events in auto-delete job (#1975)
Org-required workflows via rulesets only fire pull_request events, not push. Extend the delete-vulnerable-branch job to handle both, using the correct ref and actor for each event type.
1 parent 24a81c0 commit 648a1ae

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

.github/workflows/reusable-zizmor.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,8 @@ jobs:
692692
always() &&
693693
inputs.auto-delete-dangerous-branches &&
694694
needs.analysis.outputs.has-dangerous-triggers == 'true' &&
695-
github.event_name == 'push' &&
696-
github.ref != format('refs/heads/{0}', github.event.repository.default_branch)
695+
(github.event_name == 'push' || github.event_name == 'pull_request') &&
696+
(github.event_name != 'push' || github.ref != format('refs/heads/{0}', github.event.repository.default_branch))
697697
runs-on: ${{ inputs.runs-on }}
698698
permissions:
699699
contents: write
@@ -713,7 +713,7 @@ jobs:
713713
continue-on-error: true
714714
env:
715715
GH_TOKEN: ${{ github.token }}
716-
REF: ${{ github.ref }}
716+
REF: ${{ github.event_name == 'pull_request' && format('refs/heads/{0}', github.head_ref) || github.ref }}
717717
REPO: ${{ github.repository }}
718718
run: |
719719
gh api -X DELETE "repos/${REPO}/git/${REF}"
@@ -722,8 +722,8 @@ jobs:
722722
id: slack-payload
723723
env:
724724
REPO: ${{ github.repository }}
725-
REF_NAME: ${{ github.ref_name }}
726-
ACTOR: ${{ github.actor }}
725+
REF_NAME: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}
726+
ACTOR: ${{ github.event_name == 'pull_request' && github.event.pull_request.user.login || github.actor }}
727727
SHA: ${{ github.sha }}
728728
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
729729
SLACK_CHANNEL_ID: ${{ inputs.auto-delete-slack-channel-id }}

0 commit comments

Comments
 (0)