@@ -340,6 +340,24 @@ async function checkIfCanMergeWithoutAsanaTask({ repository, pullRequest }) {
340340 return false ;
341341}
342342
343+ function getAwsAmplifyLiveUrls ( { id, labels, amplifyUri } ) {
344+ if ( ! amplifyUri ) {
345+ return [ ] ;
346+ }
347+ const result = [ ] ;
348+ if ( amplifyUri . match ( / ^ { / ) ) {
349+ const amplifyUris = JSON . parse ( amplifyUri ) ;
350+ for ( const label of labels ) {
351+ if ( amplifyUris [ label ] ) {
352+ result . push ( amplifyUris [ label ] . replace ( "%" , id ) ) ;
353+ }
354+ }
355+ } else {
356+ result . push ( amplifyUri . replace ( "%" , id ) ) ;
357+ }
358+ return result ;
359+ }
360+
343361exports . action = async function action ( ) {
344362 // check if we run on a merge_group
345363 const {
@@ -366,6 +384,7 @@ exports.action = async function action() {
366384 } ) ;
367385 //console.log("pull", pullRequest);
368386 console . log ( "asanaPRStatus" , asanaPRStatus ) ;
387+ const labels = pullRequest . labels . map ( ( { name } ) => name ) ;
369388
370389 console . info ( `Calling action ${ action } ` ) ;
371390 switch ( action ) {
@@ -379,14 +398,16 @@ exports.action = async function action() {
379398 if ( ! taskId ) {
380399 console . log ( "Cannot update Asana task: no taskId was found" ) ;
381400 } else {
401+ const amplifyLiveUrls = getAwsAmplifyLiveUrls ( {
402+ id : pullRequest . html_url . split ( "/" ) ,
403+ labels,
404+ amplifyUri,
405+ } ) ;
382406 const updateOptions = {
383407 custom_fields : {
384- ...( amplifyUri
408+ ...( amplifyLiveUrls . length
385409 ? {
386- [ customFieldLive . gid ] : amplifyUri . replace (
387- "%" ,
388- pullRequest . html_url . split ( "/" ) . pop ( )
389- ) ,
410+ [ customFieldLive . gid ] : amplifyLiveUrls . join ( " " ) ,
390411 }
391412 : { } ) ,
392413 ...( storybookAmplifyUri
0 commit comments