@@ -4,6 +4,7 @@ import { GitHub, getOctokitOptions } from '@actions/github/lib/utils';
44import { throttling } from '@octokit/plugin-throttling' ;
55import { Context } from '@actions/github/lib/context' ;
66import { Octokit } from '@octokit/rest' ;
7+ import type { PullRequestEvent } from '@octokit/webhooks-types' ;
78import { stripIndent as markdown } from 'common-tags' ;
89import { ThemeCheckReport , ThemeCheckOffense } from './types' ;
910import * as path from 'path' ;
@@ -79,7 +80,6 @@ export async function addAnnotations(
7980 const themeRoot = core . getInput ( 'theme_root' ) ;
8081 const version = core . getInput ( 'version' ) ;
8182 const flags = core . getInput ( 'flags' ) ;
82-
8383 const octokit = new ThrottledOctokit ( {
8484 ...getOctokitOptions ( ghToken ) ,
8585 throttle : {
@@ -113,28 +113,26 @@ export async function addAnnotations(
113113
114114 console . log ( 'Creating GitHub check...' ) ;
115115
116- const root = path . resolve ( cwd , themeRoot ) ;
117-
118116 const result : ThemeCheckReport [ ] = reports . filter (
119117 getDiffFilter (
120- root ,
118+ path . resolve ( cwd , themeRoot ) ,
121119 fileDiff ?. map ( ( x ) => path . join ( cwd , x ) ) ,
122120 ) ,
123121 ) ;
124122
125123 // Create check
124+ const prPayload = github . context . payload as PullRequestEvent
126125 const check = await octokit . rest . checks . create ( {
127- owner : ctx . repo . owner ,
128- repo : ctx . repo . repo ,
126+ ...ctx . repo ,
129127 name : CHECK_NAME ,
130- head_sha : ctx . sha ,
128+ head_sha : github . context . eventName == 'pull_request' ? prPayload . pull_request . head . sha : github . context . sha ,
131129 status : 'in_progress' ,
132130 } ) ;
133131
134132 const allAnnotations : GitHubAnnotation [ ] = result
135- . flatMap ( ( report : ThemeCheckReport ) =>
133+ . flatMap ( ( report ) =>
136134 report . offenses . map ( ( offense ) => ( {
137- path : path . relative ( root , path . resolve ( report . path ) ) ,
135+ path : path . relative ( cwd , path . resolve ( report . path ) ) ,
138136 start_line : offense . start_row + 1 ,
139137 end_line : offense . end_row + 1 ,
140138 start_column :
@@ -181,8 +179,7 @@ export async function addAnnotations(
181179 await Promise . all (
182180 annotationsChunks . map ( async ( annotations ) =>
183181 octokit . rest . checks . update ( {
184- owner : ctx . repo . owner ,
185- repo : ctx . repo . repo ,
182+ ...ctx . repo ,
186183 check_run_id : check . data . id ,
187184 output : {
188185 title : CHECK_NAME ,
@@ -195,11 +192,9 @@ export async function addAnnotations(
195192
196193 // Add final report
197194 await octokit . rest . checks . update ( {
198- owner : ctx . repo . owner ,
199- repo : ctx . repo . repo ,
195+ ...ctx . repo ,
200196 check_run_id : check . data . id ,
201197 name : CHECK_NAME ,
202- status : 'completed' ,
203198 conclusion : exitCode > 0 ? 'failure' : 'success' ,
204199 output : {
205200 title : CHECK_NAME ,
0 commit comments