Skip to content

Commit

Permalink
Merge pull request #24 from KeisukeYamashita/rebuild-action
Browse files Browse the repository at this point in the history
Rebuild the action for v1 release
  • Loading branch information
github-actions[bot] authored Nov 5, 2020
2 parents 3ee8e03 + 8bc24ec commit f16c055
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 14 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ jobs:

### Action outputs

Nothing.
| Name | Description |
| --- | --- |
| `commentID` | ID of the comment if you specify `comment` in input |

### Disclaimer

Expand Down
18 changes: 12 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "gotenks-auto-pr-merge",
"name": "auto-pull-request-merge",
"version": "1.0.0",
"description": "Merge PR automatically",
"main": "lib/main.js",
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ async function run(): Promise<void> {
checkStatus: core.getInput('checkStatus') === 'true',
comment: core.getInput('comment'),
ignoreLabels:
core.getInput('labels') === ''
core.getInput('ignoreLabels') === ''
? []
: core.getInput('labels').split(','),
: core.getInput('ignoreLabels').split(','),
failStep: core.getInput('failStep') === 'true',
intervalSeconds: Number(core.getInput('intervalSeconds')) * 1000,
labels:
Expand Down
14 changes: 11 additions & 3 deletions src/merger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,21 @@ export class Merger {
`Needed Label not included in this pull request`
)
}
core.debug(`Pull request has all need labels`)

if (
pr.labels.some(label => this.cfg.labels.includes(label.name))
!pr.labels.every(
label => !this.cfg.ignoreLabels.includes(label.name)
)
) {
throw new Error(
`This pull request contains labels that should be ignored`
`This pull request contains labels that should be ignored, labels:${inspect(
pr.labels.map(l => l.name)
)}`
)
}

core.debug(`Pull request doesn't have ignore labels`)
}

if (this.cfg.checkStatus) {
Expand Down Expand Up @@ -93,14 +100,15 @@ export class Merger {
)

if (this.cfg.comment) {
await client.issues.createComment({
const {data: resp} = await client.issues.createComment({
owner: this.cfg.owner,
repo: this.cfg.repo,
issue_number: this.cfg.pullRequestNumber,
body: this.cfg.comment
})

core.debug(`Post comment ${inspect(this.cfg.comment)}`)
core.setOutput(`commentID`, resp.id)
}

await client.pulls.merge({
Expand Down

0 comments on commit f16c055

Please sign in to comment.