Skip to content

Commit

Permalink
feat: add support for merge comment
Browse files Browse the repository at this point in the history
  • Loading branch information
salmanm committed Dec 21, 2020
1 parent 79ed722 commit 9c0ee55
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ This action automatically merges dependabot PRs.

*Optional* An array of packages that you don't want to auto-merge and would like to manually review to decide whether to upgrade or not.

### `merge-method`

*Optional* The merge method you would like to use (squash, merge, rebase). Default to `squash` merge.

### `merge-comment`

*Optional* An arbitrary message that you'd like to comment on the PR after it gets auto-merged. This is only useful when you're recieving too much of noise in email and would like to filter mails for PRs that got automatically merged.

## Example usage

```yml
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ inputs:
description: "The merge method you would like to use (squash, merge, rebase)"
required: false
default: "squash"
merge-comment:
description: "An arbitrary message that you'd like to comment on the PR after it gets auto-merged"
required: false
default: ""
runs:
using: "node12"
main: "src/index.js"
12 changes: 11 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const github = require('@actions/github')
const { logInfo } = require('./log')
const { getInputs } = require('./util')

const { GITHUB_TOKEN, MERGE_METHOD, EXCLUDE_PKGS } = getInputs()
const { GITHUB_TOKEN, MERGE_METHOD, EXCLUDE_PKGS, MERGE_COMMENT } = getInputs()

async function run () {
try {
Expand Down Expand Up @@ -41,6 +41,16 @@ async function run () {
pull_number: prNumber,
merge_method: MERGE_METHOD
})


if (MERGE_COMMENT) {
await octokit.issues.createComment({
owner,
repo,
issue_number: prNumber,
body: MERGE_COMMENT,
});
}
} catch (error) {
core.setFailed(error.message)
}
Expand Down
3 changes: 2 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ const getMergeMethod = () => {
exports.getInputs = () => ({
GITHUB_TOKEN: core.getInput('github-token', { required: true }),
MERGE_METHOD: getMergeMethod(),
EXCLUDE_PKGS: core.getInput('exclude') || []
EXCLUDE_PKGS: core.getInput('exclude') || [],
MERGE_COMMENT: core.getInput('merge-comment') || ''
})

0 comments on commit 9c0ee55

Please sign in to comment.