11import * as core from '@actions/core' ;
2+ import { context } from '@actions/github' ;
3+ import type { PullRequestEvent } from '@octokit/webhooks-definitions/schema' ;
24import * as yaml from 'js-yaml' ;
35import { read } from './file' ;
46import type { Deployment , RiffraffYaml } from './riffraff' ;
@@ -190,6 +192,16 @@ const getRoleArn = (): string => {
190192 return roleArn ;
191193} ;
192194
195+ const getRevision = ( ) : string => {
196+ if ( context . eventName === 'pull_request' ) {
197+ // See https://github.com/orgs/community/discussions/26325
198+ const payload = context . payload as PullRequestEvent ;
199+ return payload . pull_request . head . sha ;
200+ } else {
201+ return context . sha ;
202+ }
203+ } ;
204+
193205export function getConfiguration ( ) : Configuration {
194206 const riffRaffYaml = getRiffRaffYaml ( ) ;
195207 const projectName = getProjectName ( riffRaffYaml ) ;
@@ -215,7 +227,7 @@ export function getConfiguration(): Configuration {
215227 buildNumber,
216228 branchName : branchName ( ) ?? 'dev' ,
217229 vcsURL : vcsURL ( ) ?? 'dev' ,
218- revision : envOrUndefined ( 'GITHUB_SHA' ) ?? 'dev' ,
230+ revision : getRevision ( ) ,
219231 deployments : getDeployments ( ) ,
220232 stagingDirInput,
221233 githubToken : githubToken ( ) ,
0 commit comments