Skip to content

Commit

Permalink
feat: support default issueNumber get from context (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg authored Aug 13, 2021
1 parent b395ad4 commit f76bae5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 29 deletions.
26 changes: 13 additions & 13 deletions README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ jobs:
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | |
| issue-number | The number of issue. When not input, it will be obtained from the trigger event | number | |
| assignees | Designated person. No operation when no input or empty character | string | ✖ |
| random-to | When set, it will be randomly selected in assignees | number | ✖ |
Expand Down Expand Up @@ -271,7 +271,7 @@ jobs:
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | |
| issue-number | The number of issue. When not input, it will be obtained from the trigger event | number | |
| labels | New labels. When it is not filled in or is empty character, do not add | string | ✖ |

- `labels` support multiple and separated by comma
Expand All @@ -295,7 +295,7 @@ Close the specified issue.
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | |
| issue-number | The number of issue. When not input, it will be obtained from the trigger event | number | |

⏫ [Back to list](#List)

Expand Down Expand Up @@ -332,7 +332,7 @@ jobs:
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | |
| issue-number | The number of issue. When not input, it will be obtained from the trigger event | number | |
| body | Add comment content | string | ✖ |
| contents | Add [reaction](#reactions-types) | string | ✖ |

Expand Down Expand Up @@ -467,7 +467,7 @@ jobs:
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | |
| issue-number | The number of issue. When not input, it will be obtained from the trigger event | number | |
| lock-reason | Reason for locking issue | string | ✖ |

- `lock-reason`: Optional values are `off-topic` `too heated` `resolved` `spam`
Expand Down Expand Up @@ -536,7 +536,7 @@ Open the specified issue.
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | |
| issue-number | The number of issue. When not input, it will be obtained from the trigger event | number | |

⏫ [Back to list](#List)

Expand All @@ -558,7 +558,7 @@ Remove the person designated by issue.
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | |
| issue-number | The number of issue. When not input, it will be obtained from the trigger event | number | |
| assignees | Designated person removed. When it is an empty character, do not remove | string | ✔ |

⏫ [Back to list](#List)
Expand All @@ -581,7 +581,7 @@ Remove the specified labels.
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | |
| issue-number | The number of issue. When not input, it will be obtained from the trigger event | number | |
| labels | The removed labels. When it is a blank character, do not remove | string | ✔ |

- `labels` supports multiple, such as `x1,x2,x3`, only the labels added by the issue will be removed
Expand All @@ -606,7 +606,7 @@ Replace the labels of issue.
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | |
| issue-number | The number of issue. When not input, it will be obtained from the trigger event | number | |
| labels | labels set. When empty characters, will remove all | string | ✔ |

⏫ [Back to list](#List)
Expand All @@ -628,7 +628,7 @@ Unlock the specified issue.
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | |
| issue-number | The number of issue. When not input, it will be obtained from the trigger event | number | |

⏫ [Back to list](#List)

Expand Down Expand Up @@ -698,7 +698,7 @@ Update the specified issue according to the `issue-number`.
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | |
| issue-number | The number of issue. When not input, it will be obtained from the trigger event | number | |
| state | Modify the status of issue, optional value `open` `closed` | string | ✖ |
| title | Modify the title of the issue | string | ✖ |
| body | Modify the content of issue | string | ✖ |
Expand Down Expand Up @@ -840,7 +840,7 @@ jobs:
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | |
| issue-number | The number of issue. When not input, it will be obtained from the trigger event | number | |
| assignee-includes | Assignees contains check | string | ✖ |
| title-includes | Title contains check | string | ✖ |
| title-excludes | Check whether the title is empty after removing the default title | string | ✖ |
Expand Down Expand Up @@ -915,7 +915,7 @@ Find the current warehouse issue No. 1, the creator is k and the content contain
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | |
| issue-number | The number of issue. When not input, it will be obtained from the trigger event | number | |
| comment-auth | Comment creator, all will be queried if not filled | string | ✖ |
| body-includes | Comment content includes filtering, no verification if not filled | string | ✖ |
| direction | Return `comments` sort | string | ✖ |
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ jobs:
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | |
| issue-number | 指定的 issue,当不传时会从触发事件中获取 | number | |
| assignees | 指定人。当不填或者为空字符时,不操作 | string | ✖ |
| random-to | 当设置时,会在 assignees 中随机选择 | number | ✖ |
Expand Down Expand Up @@ -275,7 +275,7 @@ jobs:
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | |
| issue-number | 指定的 issue,当不传时会从触发事件中获取 | number | |
| labels | 新增的 labels。当不填或者为空字符时,不新增 | string | ✖ |

- `labels` 支持多个,需用逗号隔开
Expand All @@ -299,7 +299,7 @@ jobs:
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | |
| issue-number | 指定的 issue,当不传时会从触发事件中获取 | number | |

⏫ [返回列表](#列-表)

Expand Down Expand Up @@ -336,7 +336,7 @@ jobs:
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | |
| issue-number | 指定的 issue,当不传时会从触发事件中获取 | number | |
| body | 新增评论的内容 | string | ✖ |
| contents | 为新增评论的增加 [reaction](#reactions-types) | string | ✖ |

Expand Down Expand Up @@ -471,7 +471,7 @@ jobs:
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | |
| issue-number | 指定的 issue,当不传时会从触发事件中获取 | number | |
| lock-reason | 锁定 issue 的原因 | string | ✖ |

- `lock-reason`:可选值有 `off-topic` `too heated` `resolved` `spam`
Expand Down Expand Up @@ -540,7 +540,7 @@ jobs:
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | |
| issue-number | 指定的 issue,当不传时会从触发事件中获取 | number | |

⏫ [返回列表](#列-表)

Expand All @@ -562,7 +562,7 @@ jobs:
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | |
| issue-number | 指定的 issue,当不传时会从触发事件中获取 | number | |
| assignees | 移除的指定人。当为空字符时,不进行移除 | string | ✔ |

⏫ [返回列表](#列-表)
Expand All @@ -585,7 +585,7 @@ jobs:
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | |
| issue-number | 指定的 issue,当不传时会从触发事件中获取 | number | |
| labels | 移除的 labels。当为空字符时,不进行移除 | string | ✔ |

- `labels` 支持多个,如 `x1,x2,x3`,只会移除 issue 已添加的 labels
Expand All @@ -610,7 +610,7 @@ jobs:
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | |
| issue-number | 指定的 issue,当不传时会从触发事件中获取 | number | |
| labels | labels 设置。当空字符时,会移除所有 | string | ✔ |

⏫ [返回列表](#列-表)
Expand All @@ -632,7 +632,7 @@ jobs:
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | |
| issue-number | 指定的 issue,当不传时会从触发事件中获取 | number | |

⏫ [返回列表](#列-表)

Expand Down Expand Up @@ -702,7 +702,7 @@ jobs:
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | |
| issue-number | 指定的 issue,当不传时会从触发事件中获取 | number | |
| state | 修改 issue 的状态,可选值 `open` `closed` | string | ✖ |
| title | 修改 issue 的标题 | string | ✖ |
| body | 修改 issue 的内容 | string | ✖ |
Expand Down Expand Up @@ -838,7 +838,7 @@ jobs:
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | |
| issue-number | 指定的 issue,当不传时会从触发事件中获取 | number | |
| assignee-includes | 是否包含指定人 | string | ✖ |
| title-includes | 标题包含校验 | string | ✖ |
| title-excludes | 检测标题移除默认 title 后是否为空 | string | ✖ |
Expand Down Expand Up @@ -913,7 +913,7 @@ jobs:
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | |
| issue-number | 指定的 issue,当不传时会从触发事件中获取 | number | |
| comment-auth | 评论创建者,不填时会查询所有 | string | ✖ |
| body-includes | 评论内容包含过滤,不填时无校验 | string | ✖ |
| direction | 返回 `comments` 排序 | string | ✖ |
Expand Down
9 changes: 6 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ const ALLACTIONS = [
// **************************************************************************
async function main() {
try {
const owner = github.context.repo.owner;
const repo = github.context.repo.repo;
const ctx = github.context;
const { owner, repo } = ctx.repo;

const issueNumber = core.getInput('issue-number');
let defaultNo;
if (ctx.eventName === 'issues') defaultNo = ctx.payload.issue.number;

const issueNumber = core.getInput('issue-number') || defaultNo;
const commentId = core.getInput('comment-id');

const defaultBody = `Currently at ${owner}/${repo}. And this is default comment.`;
Expand Down

0 comments on commit f76bae5

Please sign in to comment.