import * as core from '@actions/core' ; import * as github from '@actions/github' ; export const setCheckRunOutput = async ( text ) : Promise < void > => { if ( text === '' ) return ; const token = process . env [ 'GITHUB_TOKEN' ] || core . getInput ( 'token' ) ; if ( ! token || token === '' ) return ; const octokit = new github . GitHub ( token ) ; if ( ! octokit ) return ; const nwo = process . env [ 'GITHUB_REPOSITORY' ] || '/' ; const [ owner , repo ] = nwo . split ( '/' ) ; if ( ! owner ) return ; if ( ! repo ) return ; const runId = parseInt ( process . env [ 'GITHUB_RUN_ID' ] || '' ) ; if ( Number . isNaN ( runId ) ) return ; const workflowRunResponse = await octokit . actions . getWorkflowRun ( { owner , repo , run_id : runId , } ) ; const checkSuiteUrl = ( workflowRunResponse . data as any ) . check_suite_url ; const checkSuiteId = parseInt ( checkSuiteUrl . match ( /[0-9]+$/ ) [ 0 ] , 10 ) ; const checkRunsResponse = await octokit . checks . listForSuite ( { owner , repo , check_name : 'Autograding' , check_suite_id : checkSuiteId , } ) ; const checkRun = checkRunsResponse . data . total_count === 1 && checkRunsResponse . data . check_runs [ 0 ] ; if ( ! checkRun ) return ; await octokit . checks . update ( { owner , repo , check_run_id : checkRun . id , output : { title : 'Autograding' , summary : text , text : text , annotations : [ { path : '.github' , start_line : 1 , end_line : 1 , annotation_level : 'notice' , message : text , title : 'Autograding complete' , } , ] , } , } ) ; } ;