Skip to content

Commit

Permalink
feat: add number
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg committed Feb 18, 2021
1 parent 75004d8 commit c3bc9db
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.1.0

- feat: add `number`.

## v1.0.0

`2021.02.18`
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ jobs:
| Name | Desc | Type | Required |
| -- | -- | -- | -- |
| token | GitHub token | string | ✖ |
| number | Manually control the issue or PR number | string | ✖ |
| body | Create comment body | string | ✔ |
| emojis | Add [emoji](#emoji-list) | string | ✖ |
| update-mode | Comment update mode. Options: `replace` `append`. Default: `replace` | string | ✖ |
| comment-auth | Filter comment auth | string | ✖ |
| body-include | Filter comment body | string | ✖ |

- `number`: When no input, it will be the issue or PR number that triggered. When input, it is the highest priority

## Emoji List

| input | emoji |
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ inputs:
required: true
emojis:
description: Add emojis to comment.
number:
description: Manually control the issue or PR number
update-mode:
description: Update comment mode. Default replace. Option append.
comment-auth:
Expand Down
9 changes: 7 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7069,14 +7069,19 @@ async function run() {
const commentAuth = core.getInput('comment-auth');
const bodyInclude = core.getInput('body-include');

// 手动 number
const inputNumber = core.getInput('number');

let number;
if (context.eventName.includes('issue')) {
if (inputNumber) {
number = inputNumber;
} else if (context.eventName.includes('issue')) {
number = context.payload.issue.number;
} else if (context.eventName.includes('pull_request')) {
number = context.payload.pull_request.number;
} else {
core.info(
`Now eventName: ${context.eventName}. This Action only support issue and pull_request related!`,
`Now eventName: ${context.eventName}. And input number is empty. This Action only support issue and pull_request related!`,
);
return false;
}
Expand Down
9 changes: 7 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ async function run() {
const commentAuth = core.getInput('comment-auth');
const bodyInclude = core.getInput('body-include');

// 手动 number
const inputNumber = core.getInput('number');

let number;
if (context.eventName.includes('issue')) {
if (inputNumber) {
number = inputNumber;
} else if (context.eventName.includes('issue')) {
number = context.payload.issue.number;
} else if (context.eventName.includes('pull_request')) {
number = context.payload.pull_request.number;
} else {
core.info(
`Now eventName: ${context.eventName}. This Action only support issue and pull_request related!`,
`Now eventName: ${context.eventName}. And input number is empty. This Action only support issue and pull_request related!`,
);
return false;
}
Expand Down

0 comments on commit c3bc9db

Please sign in to comment.