Skip to content

Commit

Permalink
add auto_merge (defaults true)
Browse files Browse the repository at this point in the history
  • Loading branch information
splitice committed Oct 27, 2021
1 parent e32e0bf commit 870ddf9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ inputs:
description: 'Automatically approve pull request before merge'
required: false
default: false
auto_merge:
description: 'Automatically merge the pull request'
required: false
default: true
retries:
description: 'Retry count'
required: false
Expand Down
5 changes: 4 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function run() {
const prMessage = core.getInput('pr_message', { required: false });
const ignoreFail = core.getBooleanInput('ignore_fail', { required: false });
const autoApprove = core.getBooleanInput('auto_approve', { required: false });
const autoMerge = core.getBooleanInput('auto_merge', { required: false });
const retries = parseInt(core.getInput('retries', { required: false })) || 4;
const retryAfter = parseInt(core.getInput('retry_after', { required: false })) || 60;
const octokit = new MyOctokit({
Expand All @@ -70,7 +71,9 @@ function run() {
yield octokit.pulls.createReview({ owner: context.repo.owner, repo, pull_number: pr.data.number, event: "COMMENT", body: "Auto approved" });
yield octokit.pulls.createReview({ owner: context.repo.owner, repo, pull_number: pr.data.number, event: "APPROVE" });
}
yield octokit.pulls.merge({ owner: context.repo.owner, repo, pull_number: pr.data.number, merge_method: mergeMethod });
if (autoMerge) {
yield octokit.pulls.merge({ owner: context.repo.owner, repo, pull_number: pr.data.number, merge_method: mergeMethod });
}
}
catch (error) {
if (error.request.request.retryCount) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fork-sync",
"version": "1.6.1",
"version": "1.6.2",
"private": true,
"description": "Keep your fork up to date",
"main": "lib/main.js",
Expand Down
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ async function run() {
const prMessage = core.getInput('pr_message', { required: false });
const ignoreFail = core.getBooleanInput('ignore_fail', { required: false });
const autoApprove = core.getBooleanInput('auto_approve', { required: false });
const autoMerge = core.getBooleanInput('auto_merge', { required: false });
const retries = parseInt(core.getInput('retries', { required: false })) || 4;
const retryAfter = parseInt(core.getInput('retry_after', { required: false })) || 60;

Expand Down Expand Up @@ -44,7 +45,9 @@ async function run() {
await octokit.pulls.createReview({ owner: context.repo.owner, repo, pull_number: pr.data.number, event: "COMMENT", body: "Auto approved" });
await octokit.pulls.createReview({ owner: context.repo.owner, repo, pull_number: pr.data.number, event: "APPROVE" });
}
await octokit.pulls.merge({ owner: context.repo.owner, repo, pull_number: pr.data.number, merge_method: mergeMethod });
if(autoMerge) {
await octokit.pulls.merge({ owner: context.repo.owner, repo, pull_number: pr.data.number, merge_method: mergeMethod });
}
} catch (error) {
if (error.request.request.retryCount) {
console.log(
Expand Down

0 comments on commit 870ddf9

Please sign in to comment.