@@ -26,12 +26,37 @@ jobs:
2626 with :
2727 ref : ${{ github.event.pull_request.head.ref }}
2828
29+ # For fork PRs that are manually triggered, we need to get the PR details first
30+ - name : Get PR details for fork
31+ if : ${{ github.event_name == 'workflow_dispatch' }}
32+ id : pr_details
33+ uses : actions/github-script@v7
34+ with :
35+ script : |
36+ const prNumber = ${{ inputs.pull_request_number }};
37+
38+ // Get PR details to find the head SHA
39+ const { data: pr } = await github.rest.pulls.get({
40+ owner: context.repo.owner,
41+ repo: context.repo.repo,
42+ pull_number: prNumber
43+ });
44+
45+ console.log(`Fork PR head SHA: ${pr.head.sha}`);
46+ console.log(`Fork PR head ref: ${pr.head.ref}`);
47+ console.log(`Fork PR repo: ${pr.head.repo.full_name}`);
48+
49+ // Set outputs for checkout step
50+ core.setOutput('head_sha', pr.head.sha);
51+ core.setOutput('head_ref', pr.head.ref);
52+ core.setOutput('repo_full_name', pr.head.repo.full_name);
53+
2954 - name : Checkout for manually triggered fork PR
3055 if : ${{ github.event_name == 'workflow_dispatch' }}
3156 uses : actions/checkout@v4
3257 with :
33- ref : ${{ github.sha }}
34- repository : ${{ github.event.pull_request.head.repo.full_name }}
58+ ref : ${{ steps.pr_details.outputs.head_sha }}
59+ repository : ${{ steps.pr_details.outputs.repo_full_name }}
3560
3661 - name : Setup Ruby
3762 uses : ruby/setup-ruby@v1
77102 if ('${{ github.event_name }}' === 'pull_request') {
78103 commitSha = '${{ github.event.pull_request.head.sha }}';
79104 } else {
80- // For workflow_dispatch, get the SHA from the current commit
81- commitSha = '${{ github.sha }}';
105+ // For workflow_dispatch, get the SHA from the PR details
106+ commitSha = '${{ steps.pr_details.outputs.head_sha }}';
82107 }
83108
84109 // Get all comments on the PR
0 commit comments