@@ -278,23 +278,24 @@ export class Action {
278
278
debug ( `GITHUB_REF: ${ GITHUB_REF } ` ) ;
279
279
debug ( `GITHUB_BASE_REF: ${ GITHUB_BASE_REF } ` ) ;
280
280
debug ( `GITHUB_HEAD_REF: ${ GITHUB_HEAD_REF } ` ) ;
281
- debug ( `Is PR: ${ this . isPr } ` ) ;
282
281
debug ( `Branch Type: ${ branchType } ` ) ;
283
282
debug ( `Branch ID: ${ branchId } ` ) ;
283
+ debug ( `PR Number: ${ this . prNumber } ` ) ;
284
284
285
285
if ( ! branchId ) {
286
- debug ( `GITHUB_REF: ${ GITHUB_REF } ` ) ;
287
- debug ( `branchType: ${ branchType } ` ) ;
288
- debug ( `branchId: ${ branchId } ` ) ;
289
286
throw new Error ( 'Unable to determine branch from GITHUB_REF' ) ;
290
287
}
291
288
292
289
let deploymentStage = branchId ;
293
- if ( branchType === 'pull' ) {
290
+ if ( this . prNumber ) {
294
291
if ( ! GITHUB_BASE_REF ) {
295
292
throw new Error ( 'Unable to determine base ref from GITHUB_BASE_REF' ) ;
296
293
}
297
- deploymentStage = `${ GITHUB_BASE_REF . replaceAll ( '/' , '-' ) } -pr-${ branchId } ` ;
294
+
295
+ const normalizedBaseRef = GITHUB_BASE_REF . replaceAll ( '/' , '-' ) ;
296
+ debug ( 'Normalized Base Ref: ' + normalizedBaseRef ) ;
297
+
298
+ deploymentStage = `${ normalizedBaseRef } -pr-${ this . prNumber } ` ;
298
299
}
299
300
300
301
return deploymentStage ;
@@ -349,18 +350,14 @@ export class Action {
349
350
350
351
get prNumber ( ) : number | undefined {
351
352
if ( context . eventName === 'pull_request' ) {
353
+ if ( ! context . payload . pull_request || ! context . payload . pull_request . number ) {
354
+ throw new Error ( 'Unable to determine PR number' ) ;
355
+ }
352
356
return context . payload . pull_request ?. number ;
353
357
}
354
358
return undefined ;
355
359
}
356
360
357
- get isPr ( ) : boolean {
358
- if ( ! GITHUB_REF ) {
359
- throw new Error ( 'Unable to determine Pull Request from GITHUB_REF' ) ;
360
- }
361
- return GITHUB_REF . endsWith ( '/merge' ) ;
362
- }
363
-
364
361
get workflowInputs ( ) : { [ key : string ] : string } {
365
362
return context . payload . inputs || { } ;
366
363
}
@@ -398,7 +395,7 @@ export class Action {
398
395
ref : this . deploymentRef ,
399
396
required_contexts : [ ] ,
400
397
environment : this . stage ,
401
- transient_environment : this . isPr ,
398
+ transient_environment : ! ! this . prNumber ,
402
399
auto_merge : false ,
403
400
owner : this . owner ,
404
401
repo : this . repo ,
@@ -502,7 +499,7 @@ export class Action {
502
499
} ) ,
503
500
) ;
504
501
505
- if ( this . isPr ) {
502
+ if ( this . prNumber ) {
506
503
await Promise . all (
507
504
deployments . map ( async ( deployment ) => {
508
505
try {
0 commit comments