@@ -395,15 +395,16 @@ module.exports._enoent = enoent;
395
395
/***/ 31 :
396
396
/***/ ( function ( __unusedmodule , __unusedexports , __webpack_require__ ) {
397
397
398
- const core = __webpack_require__ ( 470 ) ;
399
- const github = __webpack_require__ ( 469 ) ;
398
+ const core = __webpack_require__ ( 470 ) ,
399
+ github = __webpack_require__ ( 469 ) ;
400
400
401
401
const token = core . getInput ( "github-token" , { required : true } ) ,
402
402
releaseBranch = getBranch ( "release" ) ,
403
403
devBranch = getBranch ( "dev" ) ,
404
404
masterBranch = getBranch ( "master" ) ,
405
405
label = getInput ( "label" , "gitflow" ) ,
406
- auto_merge = getInput ( "auto-merge" , "true" ) == "true" ,
406
+ auto_merge = getInput ( "auto-merge" , "true" ) ,
407
+ require_merge = getInput ( "require-merge" , "false" ) == "true" ,
407
408
context = github . context ,
408
409
owner = context . repo . owner ,
409
410
repo = context . repo . repo ,
@@ -426,6 +427,16 @@ function getTarget(head) {
426
427
}
427
428
}
428
429
430
+ function isAutoMergeEvent ( eventName ) {
431
+ if ( auto_merge == "true" ) {
432
+ return true ;
433
+ }
434
+ else {
435
+ const auto_merge_events = auto_merge . split ( "," ) . map ( e => e . trim ( ) ) ;
436
+ return auto_merge_events . includes ( eventName ) ;
437
+ }
438
+ }
439
+
429
440
async function run ( ) {
430
441
try {
431
442
core . debug ( JSON . stringify ( context . payload ) ) ;
@@ -435,7 +446,7 @@ async function run() {
435
446
break ;
436
447
437
448
case "pull_request_review" :
438
- if ( auto_merge ) {
449
+ if ( isAutoMergeEvent ( "pull_request_review" ) ) {
439
450
if ( context . payload . pull_request . labels . map ( labelMap ) . includes ( label ) ) {
440
451
await merge ( context . payload . pull_request . number ) ;
441
452
}
@@ -444,13 +455,18 @@ async function run() {
444
455
}
445
456
}
446
457
else {
447
- core . info ( "Auto merge is disabled. You should remove the `pull_request_review` event from the action configuration. Skipping..." ) ;
458
+ core . info ( "Auto merge is disabled for pull-request reviews . You should remove the `pull_request_review` event from the action configuration. Skipping..." ) ;
448
459
}
449
460
break ;
450
461
451
462
case "check_run" :
452
- if ( auto_merge ) {
453
- for ( const element of context . payload . check_run . pull_requests ) {
463
+ if ( isAutoMergeEvent ( "check_run" ) ) {
464
+ var prs = context . payload . check_run . pull_requests ;
465
+ if ( ! prs ) {
466
+ core . info ( "Empty pull request list. Stepping out..." ) ;
467
+ return ;
468
+ }
469
+ for ( const element of prs ) {
454
470
const pullResponse = await client . pulls . get ( {
455
471
owner,
456
472
pull_number : element . number ,
@@ -467,7 +483,7 @@ async function run() {
467
483
}
468
484
}
469
485
else {
470
- core . info ( "Auto merge is disabled. You should remove the `check_run` event from the action configuration. Skipping..." ) ;
486
+ core . info ( "Auto merge is disabled for check runs . You should remove the `check_run` event from the action configuration. Skipping..." ) ;
471
487
}
472
488
break ;
473
489
}
@@ -530,11 +546,11 @@ async function push() {
530
546
core . info ( `Label ${ label } added to #${ pull_number } .` ) ;
531
547
core . debug ( JSON . stringify ( labelsResponse . data ) ) ;
532
548
}
533
- if ( auto_merge ) {
549
+ if ( isAutoMergeEvent ( "push" ) ) {
534
550
await merge ( pull_number ) ;
535
551
}
536
552
else {
537
- core . info ( "Auto merge is disabled. Skipping..." ) ;
553
+ core . info ( "Auto merge is disabled for pushes . Skipping..." ) ;
538
554
}
539
555
}
540
556
@@ -549,7 +565,11 @@ async function merge(pull_number) {
549
565
core . debug ( JSON . stringify ( mergeResponse . data ) ) ;
550
566
}
551
567
catch ( err ) {
552
- core . info ( "Merge failed." ) ;
568
+ if ( require_merge ) {
569
+ core . setFailed ( "Merge failed." ) ;
570
+ } else {
571
+ core . info ( "Merge failed." ) ;
572
+ }
553
573
core . debug ( err ) ;
554
574
}
555
575
}
0 commit comments