@@ -202,13 +202,13 @@ function getCommitFromPullRequestPayload(pr: PullRequest): Commit {
202202 } ;
203203}
204204
205- async function getCommitFromGitHubAPIRequest ( githubToken : string ) : Promise < Commit > {
205+ async function getCommitFromGitHubAPIRequest ( githubToken : string , commitSha ?: string ) : Promise < Commit > {
206206 const octocat = new github . GitHub ( githubToken ) ;
207207
208208 const { status, data } = await octocat . repos . getCommit ( {
209209 owner : github . context . repo . owner ,
210210 repo : github . context . repo . repo ,
211- ref : github . context . ref ,
211+ ref : commitSha ?? github . context . ref ,
212212 } ) ;
213213
214214 if ( ! ( status === 200 || status === 304 ) ) {
@@ -235,7 +235,11 @@ async function getCommitFromGitHubAPIRequest(githubToken: string): Promise<Commi
235235 } ;
236236}
237237
238- async function getCommit ( githubToken ?: string ) : Promise < Commit > {
238+ async function getCommit ( githubToken ?: string , commitSha ?: string ) : Promise < Commit > {
239+ if ( commitSha && githubToken ) {
240+ return getCommitFromGitHubAPIRequest ( githubToken , commitSha ) ;
241+ }
242+
239243 if ( github . context . payload . head_commit ) {
240244 return github . context . payload . head_commit ;
241245 }
@@ -564,7 +568,7 @@ function extractCustomBenchmarkResult(output: string): BenchmarkResult[] {
564568
565569export async function extractResult ( config : Config ) : Promise < Benchmark > {
566570 const output = await fs . readFile ( config . outputFilePath , 'utf8' ) ;
567- const { tool, githubToken } = config ;
571+ const { tool, githubToken, commitSha } = config ;
568572 let benches : BenchmarkResult [ ] ;
569573
570574 switch ( tool ) {
@@ -603,7 +607,7 @@ export async function extractResult(config: Config): Promise<Benchmark> {
603607 throw new Error ( `No benchmark result was found in ${ config . outputFilePath } . Benchmark output was '${ output } '` ) ;
604608 }
605609
606- const commit = await getCommit ( githubToken ) ;
610+ const commit = await getCommit ( githubToken , commitSha ) ;
607611
608612 return {
609613 commit,
0 commit comments