Skip to content

Commit 6e5cd11

Browse files
committed
fix: PR Linter to handle pull_request_target events
1 parent 4c079f2 commit 6e5cd11

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

.github/workflows/pr-linter.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
download-if-workflow-run:
2727
runs-on: ubuntu-latest
2828
outputs:
29-
pr_number: ${{ steps.pr_output.outputs.pr_number }}
30-
pr_sha: ${{ steps.pr_output.outputs.pr_sha }}
29+
pr_number: ${{ steps.pr_output.outputs.pr_number || steps.pr_output_target.outputs.pr_number }}
30+
pr_sha: ${{ steps.pr_output.outputs.pr_sha || steps.pr_output_target.outputs.pr_sha }}
3131
# if conditions on all individual steps because subsequent jobs depend on this job
3232
# and we cannot skip it entirely
3333
steps:
@@ -41,7 +41,7 @@ jobs:
4141
path: pr/
4242
search_artifacts: true
4343

44-
- name: 'Determine PR info'
44+
- name: 'Determine PR info from workflow_run'
4545
# PR info comes from the artifact if downloaded, or GitHub context if not.
4646
if: github.event_name == 'workflow_run'
4747
id: 'pr_output'
@@ -56,6 +56,13 @@ jobs:
5656
echo "pr_number=$(cat pr/pr_number)" >> "$GITHUB_OUTPUT"
5757
echo "pr_sha=$(cat pr/pr_sha)" >> "$GITHUB_OUTPUT"
5858
59+
- name: 'Get PR info from pull_request_target event'
60+
if: github.event_name == 'pull_request_target'
61+
id: 'pr_output_target'
62+
run: |
63+
echo "pr_number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
64+
echo "pr_sha=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
65+
5966
validate-pr:
6067
# Necessary to have sufficient permissions to write to the PR
6168
permissions:

0 commit comments

Comments
 (0)