@@ -359,6 +359,16 @@ function getAwsAmplifyLiveUrls({ id, labels, amplifyUri }) {
359359}
360360
361361exports . action = async function action ( ) {
362+ try {
363+ return await actionImpl ( ) ;
364+ } catch ( error ) {
365+ console . error ( error ) ;
366+ core . setFailed ( error . message ) ;
367+ throw error ;
368+ }
369+ } ;
370+
371+ async function actionImpl ( ) {
362372 // check if we run on a merge_group
363373 const {
364374 mergeGroup,
@@ -384,7 +394,7 @@ exports.action = async function action() {
384394 } ) ;
385395 //console.log("pull", pullRequest);
386396 console . log ( "asanaPRStatus" , asanaPRStatus ) ;
387- const labels = pullRequest . labels . map ( ( { name } ) => name ) ;
397+ const labels = ( pullRequest . labels || [ ] ) . map ( ( { name } ) => name ) ;
388398
389399 console . info ( `Calling action ${ action } ` ) ;
390400 switch ( action ) {
@@ -398,8 +408,10 @@ exports.action = async function action() {
398408 if ( ! taskId ) {
399409 console . log ( "Cannot update Asana task: no taskId was found" ) ;
400410 } else {
411+ const pullRequestNumber =
412+ pullRequest . number || pullRequest . html_url . split ( "/" ) . pop ( ) ;
401413 const amplifyLiveUrls = getAwsAmplifyLiveUrls ( {
402- id : pullRequest . html_url . split ( "/" ) ,
414+ id : pullRequestNumber ,
403415 labels,
404416 amplifyUri,
405417 } ) ;
@@ -414,7 +426,7 @@ exports.action = async function action() {
414426 ? {
415427 [ customFieldStorybook . gid ] : storybookAmplifyUri . replace (
416428 "%" ,
417- pullRequest . html_url . split ( "/" ) . pop ( )
429+ pullRequestNumber
418430 ) ,
419431 }
420432 : { } ) ,
@@ -480,4 +492,4 @@ exports.action = async function action() {
480492 break ;
481493 }
482494 }
483- } ;
495+ }
0 commit comments