File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 updateComment ,
55 listComments ,
66 addCommentToIssue ,
7- deleteComment
7+ deleteComment ,
8+ createGitHubClient
89} from '../client/github'
910import { Inputs } from '../types'
1011import { Report } from '../ctrf/core/types/ctrf'
@@ -285,10 +286,28 @@ export async function createStatusCheck(
285286 }
286287
287288 try {
289+ // Use the correct SHA for PR association
290+ let sha = context . sha
291+ if ( inputs . issue ) {
292+ try {
293+ const octokit = await createGitHubClient ( )
294+ const pr = await octokit . pulls . get ( {
295+ owner : context . repo . owner ,
296+ repo : context . repo . repo ,
297+ pull_number : parseInt ( inputs . issue )
298+ } )
299+ sha = pr . data . head . sha
300+ core . info ( `Using PR head SHA: ${ sha } for PR #${ inputs . issue } ` )
301+ } catch ( error ) {
302+ core . warning ( `Failed to fetch PR #${ inputs . issue } , using context.sha: ${ context . sha } . ${ String ( error ) } ` )
303+ sha = context . sha
304+ }
305+ }
306+
288307 await createCheckRun (
289308 context . repo . owner ,
290309 context . repo . repo ,
291- context . sha ,
310+ sha ,
292311 inputs . statusCheckName ,
293312 'completed' ,
294313 report . results . summary . failed > 0 ? 'failure' : 'success' ,
You can’t perform that action at this time.
0 commit comments