@@ -193,7 +193,21 @@ async function post() {
193193 const github_token = core . getInput ( 'github_token' ) ;
194194 const repository = process . env . GITHUB_REPOSITORY ;
195195 const [ owner , repo ] = ( repository || '' ) . split ( '/' ) ;
196- const sha = process . env . GITHUB_SHA ;
196+
197+ // Extract the correct SHA
198+ let sha = process . env . GITHUB_SHA ;
199+ // For pull requests, get the SHA from the head of the PR
200+ if ( process . env . GITHUB_EVENT_NAME === 'pull_request' && process . env . GITHUB_EVENT_PATH ) {
201+ try {
202+ const eventData = JSON . parse ( fs . readFileSync ( process . env . GITHUB_EVENT_PATH , 'utf8' ) ) ;
203+ if ( eventData . pull_request && eventData . pull_request . head && eventData . pull_request . head . sha ) {
204+ sha = eventData . pull_request . head . sha ;
205+ core . info ( `Using PR head SHA: ${ sha } instead of merged SHA` ) ;
206+ }
207+ } catch ( eventError ) {
208+ core . warning ( `Failed to parse event data: ${ eventError . message } ` ) ;
209+ }
210+ }
197211
198212 // Check if all required parameters are available for deployment
199213 if ( github_token && owner && repo && sha && projectUuid && queryUrl ) {
@@ -252,7 +266,7 @@ async function post() {
252266 core . info ( 'Skipping GitHub deployment creation due to missing required parameters:' ) ;
253267 if ( ! github_token ) core . info ( '- Missing github_token' ) ;
254268 if ( ! owner || ! repo ) core . info ( `- Missing repository information: ${ repository } ` ) ;
255- if ( ! ref ) core . info ( '- Missing ref information' ) ;
269+ if ( ! sha ) core . info ( '- Missing SHA information' ) ;
256270 if ( ! projectUuid ) core . info ( '- Missing project_uuid' ) ;
257271 if ( ! queryUrl ) core . info ( '- Missing queryUrl' ) ;
258272 }
0 commit comments