Skip to content

Commit af600fb

Browse files
committed
dist
1 parent ed07d3d commit af600fb

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

dist/index.js

+31-11
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,16 @@ module.exports._enoent = enoent;
395395
/***/ 31:
396396
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
397397

398-
const core = __webpack_require__(470);
399-
const github = __webpack_require__(469);
398+
const core = __webpack_require__(470),
399+
github = __webpack_require__(469);
400400

401401
const token = core.getInput("github-token", { required: true }),
402402
releaseBranch = getBranch("release"),
403403
devBranch = getBranch("dev"),
404404
masterBranch = getBranch("master"),
405405
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",
407408
context = github.context,
408409
owner = context.repo.owner,
409410
repo = context.repo.repo,
@@ -426,6 +427,16 @@ function getTarget(head) {
426427
}
427428
}
428429

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+
429440
async function run() {
430441
try {
431442
core.debug(JSON.stringify(context.payload));
@@ -435,7 +446,7 @@ async function run() {
435446
break;
436447

437448
case "pull_request_review":
438-
if (auto_merge) {
449+
if (isAutoMergeEvent("pull_request_review")) {
439450
if (context.payload.pull_request.labels.map(labelMap).includes(label)) {
440451
await merge(context.payload.pull_request.number);
441452
}
@@ -444,13 +455,18 @@ async function run() {
444455
}
445456
}
446457
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...");
448459
}
449460
break;
450461

451462
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) {
454470
const pullResponse = await client.pulls.get({
455471
owner,
456472
pull_number: element.number,
@@ -467,7 +483,7 @@ async function run() {
467483
}
468484
}
469485
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...");
471487
}
472488
break;
473489
}
@@ -530,11 +546,11 @@ async function push() {
530546
core.info(`Label ${label} added to #${pull_number}.`);
531547
core.debug(JSON.stringify(labelsResponse.data));
532548
}
533-
if (auto_merge) {
549+
if (isAutoMergeEvent("push")) {
534550
await merge(pull_number);
535551
}
536552
else {
537-
core.info("Auto merge is disabled. Skipping...");
553+
core.info("Auto merge is disabled for pushes. Skipping...");
538554
}
539555
}
540556

@@ -549,7 +565,11 @@ async function merge(pull_number) {
549565
core.debug(JSON.stringify(mergeResponse.data));
550566
}
551567
catch (err) {
552-
core.info("Merge failed.");
568+
if (require_merge) {
569+
core.setFailed("Merge failed.");
570+
} else {
571+
core.info("Merge failed.");
572+
}
553573
core.debug(err);
554574
}
555575
}

0 commit comments

Comments
 (0)