fix: comment many

This commit is contained in:
xrkffgg
2020-12-23 16:41:50 +08:00
parent 99cdc9fb62
commit 2feccec244
5 changed files with 45 additions and 100 deletions

View File

@@ -74,12 +74,11 @@ jobs:
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| assignees | 指定人。当不填或者为空字符、空数组时,不指定 | string \| string\[] | ✖ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
- `actions` 支持多个,需用逗号隔开。如:`add-assignees,add-labels`
- 其中的 `name` 可根据自行根据实际情况修改
- [on 参考](#github-docs)
- `${{ github.event.issue.number }}` 表示当前 issue[更多参考](https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events)
- `${{ github.event.issue.number }}` 表示当前 issue[更多参考](https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events)
⏫ [返回列表](#列-表)
@@ -114,7 +113,6 @@ jobs:
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| labels | 新增的 labels。当不填或者为空字符、空数组时不新增 | string \| string\[] | ✖ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
⏫ [返回列表](#列-表)
@@ -137,7 +135,6 @@ jobs:
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
⏫ [返回列表](#列-表)
@@ -278,7 +275,6 @@ jobs:
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
⏫ [返回列表](#列-表)
@@ -300,7 +296,6 @@ jobs:
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
⏫ [返回列表](#列-表)
@@ -324,7 +319,6 @@ jobs:
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| assignees | 移除的指定人。当为空字符、空数组时,不进行移除 | string \| string\[] | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
⏫ [返回列表](#列-表)
@@ -348,7 +342,6 @@ jobs:
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| labels | labels 设置。当空字符、空数组时,会移除所有 | string \| string\[] | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
⏫ [返回列表](#列-表)
@@ -370,7 +363,6 @@ jobs:
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| body | 解锁 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
⏫ [返回列表](#列-表)
@@ -454,6 +446,8 @@ jobs:
### ⭐ 进 阶
进阶用法不建议 actions 多重使用。
#### `check-inactive`
每月 1 号 UTC 0 时,对所有 30 天以上未活跃的 issues 增加 `inactive` 标签。

View File

@@ -62,7 +62,7 @@ jobs:
- name: Add assigness
uses: actions-cool/issue-helper@v1
with:
actions: 'add-assignees' or ['add-assignees']
actions: 'add-assignees'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
assignees: 'xxx' or ['xxx'] or ['xx1', 'xx2']
@@ -70,15 +70,15 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| assignees | 指定人。当不填或者为空字符、空数组时,不指定 | string \| string\[] | ✖ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
- `actions` 支持多个,需用逗号隔开。如:`add-assignees,add-labels`
- 其中的 `name` 可根据自行根据实际情况修改
- [on 参考](#github-docs)
- `${{ github.event.issue.number }}` 表示当前 issue[更多参考](https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events)
- `${{ github.event.issue.number }}` 表示当前 issue[更多参考](https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events)
⏫ [返回列表](#列-表)
@@ -109,11 +109,10 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| labels | 新增的 labels。当不填或者为空字符、空数组时不新增 | string \| string\[] | ✖ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
⏫ [返回列表](#列-表)
@@ -133,10 +132,9 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
⏫ [返回列表](#列-表)
@@ -171,7 +169,7 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| body | 新增评论的内容 | string | ✖ | v1 |
@@ -213,7 +211,7 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| title | 新增 issue 的标题 | string | ✖ | v1 |
| body | 新增 issue 的内容 | string | ✖ | v1 |
@@ -242,7 +240,7 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| comment-id | 指定的 comment | number | ✔ | v1 |
@@ -274,10 +272,9 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
⏫ [返回列表](#列-表)
@@ -296,10 +293,9 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
⏫ [返回列表](#列-表)
@@ -319,11 +315,10 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| assignees | 移除的指定人。当为空字符、空数组时,不进行移除 | string \| string\[] | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
⏫ [返回列表](#列-表)
@@ -343,11 +338,10 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| labels | labels 设置。当空字符、空数组时,会移除所有 | string \| string\[] | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
⏫ [返回列表](#列-表)
@@ -366,10 +360,9 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| body | 解锁 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
⏫ [返回列表](#列-表)
@@ -401,7 +394,7 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| comment-id | 指定的 comment | number | ✔ | v1 |
| body | 更新 comment 的内容 | string | ✖ | v1 |
@@ -435,7 +428,7 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| state | 修改 issue 的状态,可选值 `open` `closed` | string | ✖ | v1 |
@@ -453,6 +446,8 @@ jobs:
### ⭐ 进 阶
进阶用法不建议 actions 多重使用。
#### `check-inactive`
每月 1 号 UTC 0 时,对所有 30 天以上未活跃的 issues 增加 `inactive` 标签。
@@ -478,7 +473,7 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
| labels | 标签筛选 | string \| string\[] | ✖ | v1 |
@@ -523,7 +518,7 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
| labels | 标签筛选 | string \| string\[] | ✖ | v1 |
@@ -557,7 +552,7 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
| comment-auth | 评论创建者,不填时会查询所有 | string | ✖ | v1 |
@@ -604,7 +599,7 @@ jobs:
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
| labels | 标签筛选 | string \| string\[] | ✖ | v1 |

42
dist/index.js vendored
View File

@@ -5992,6 +5992,7 @@ dayjs.extend(isSameOrBefore);
const {
doAddLabels,
doCloseIssue,
doCreateComment,
doLockIssue
} = __webpack_require__(9932);
@@ -6025,6 +6026,9 @@ async function doCheckInactive (owner, repo, labels) {
for (let i = 0; i < issues.length; i++) {
if (!JSON.stringify(issues[i].labels).includes(inactiveLabel)) {
await doAddLabels(owner, repo, issues[i].number, inactiveLabel);
if (core.getInput("body")) {
await doCreateComment(owner, repo, issues[i].number, core.getInput("body"));
}
} else {
core.info(`Actions: [add-inactive] issue ${issues[i].number} has label!`);
}
@@ -6040,6 +6044,9 @@ async function doCloseIssues (owner, repo, labels) {
if (issues.length) {
for (let i = 0; i < issues.length; i++) {
await doCloseIssue(owner, repo, issues[i].number);
if (core.getInput("body")) {
await doCreateComment(owner, repo, issues[i].number, core.getInput("body"));
}
}
} else {
core.info(`Actions: [query-issues] empty!`);
@@ -6079,6 +6086,9 @@ async function doLockIssues (owner, repo, labels) {
if (issues.length) {
for (let i = 0; i < issues.length; i++) {
await doLockIssue(owner, repo, issues[i].number);
if (core.getInput("body")) {
await doCreateComment(owner, repo, issues[i].number, core.getInput("body"));
}
}
} else {
core.info(`Actions: [query-issues] empty!`);
@@ -6164,10 +6174,6 @@ const octokit = new Octokit({ auth: `token ${token}` });
const contents = core.getInput("contents");
async function doAddAssignees (owner, repo, issueNumber, assignees) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.addAssignees({
owner,
repo,
@@ -6178,10 +6184,6 @@ async function doAddAssignees (owner, repo, issueNumber, assignees) {
};
async function doAddLabels (owner, repo, issueNumber, labels) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.addLabels({
owner,
repo,
@@ -6192,10 +6194,6 @@ async function doAddLabels (owner, repo, issueNumber, labels) {
};
async function doCloseIssue (owner, repo, issueNumber) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.update({
owner,
repo,
@@ -6297,10 +6295,6 @@ async function doDeleteComment (owner, repo, commentId) {
};
async function doLockIssue (owner, repo, issueNumber) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.lock({
owner,
repo,
@@ -6310,10 +6304,6 @@ async function doLockIssue (owner, repo, issueNumber) {
};
async function doOpenIssue (owner, repo, issueNumber) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.update({
owner,
repo,
@@ -6324,10 +6314,6 @@ async function doOpenIssue (owner, repo, issueNumber) {
};
async function doRemoveAssignees (owner, repo, issueNumber, assignees) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.removeAssignees({
owner,
repo,
@@ -6338,10 +6324,6 @@ async function doRemoveAssignees (owner, repo, issueNumber, assignees) {
};
async function doSetLabels (owner, repo, issueNumber, labels) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.setLabels({
owner,
repo,
@@ -6352,10 +6334,6 @@ async function doSetLabels (owner, repo, issueNumber, labels) {
};
async function doUnlockIssue (owner, repo, issueNumber) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.unlock({
owner,
repo,

View File

@@ -11,6 +11,7 @@ dayjs.extend(isSameOrBefore);
const {
doAddLabels,
doCloseIssue,
doCreateComment,
doLockIssue
} = require('./base.js');
@@ -44,6 +45,9 @@ async function doCheckInactive (owner, repo, labels) {
for (let i = 0; i < issues.length; i++) {
if (!JSON.stringify(issues[i].labels).includes(inactiveLabel)) {
await doAddLabels(owner, repo, issues[i].number, inactiveLabel);
if (core.getInput("body")) {
await doCreateComment(owner, repo, issues[i].number, core.getInput("body"));
}
} else {
core.info(`Actions: [add-inactive] issue ${issues[i].number} has label!`);
}
@@ -59,6 +63,9 @@ async function doCloseIssues (owner, repo, labels) {
if (issues.length) {
for (let i = 0; i < issues.length; i++) {
await doCloseIssue(owner, repo, issues[i].number);
if (core.getInput("body")) {
await doCreateComment(owner, repo, issues[i].number, core.getInput("body"));
}
}
} else {
core.info(`Actions: [query-issues] empty!`);
@@ -98,6 +105,9 @@ async function doLockIssues (owner, repo, labels) {
if (issues.length) {
for (let i = 0; i < issues.length; i++) {
await doLockIssue(owner, repo, issues[i].number);
if (core.getInput("body")) {
await doCreateComment(owner, repo, issues[i].number, core.getInput("body"));
}
}
} else {
core.info(`Actions: [query-issues] empty!`);

View File

@@ -21,10 +21,6 @@ const octokit = new Octokit({ auth: `token ${token}` });
const contents = core.getInput("contents");
async function doAddAssignees (owner, repo, issueNumber, assignees) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.addAssignees({
owner,
repo,
@@ -35,10 +31,6 @@ async function doAddAssignees (owner, repo, issueNumber, assignees) {
};
async function doAddLabels (owner, repo, issueNumber, labels) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.addLabels({
owner,
repo,
@@ -49,10 +41,6 @@ async function doAddLabels (owner, repo, issueNumber, labels) {
};
async function doCloseIssue (owner, repo, issueNumber) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.update({
owner,
repo,
@@ -154,10 +142,6 @@ async function doDeleteComment (owner, repo, commentId) {
};
async function doLockIssue (owner, repo, issueNumber) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.lock({
owner,
repo,
@@ -167,10 +151,6 @@ async function doLockIssue (owner, repo, issueNumber) {
};
async function doOpenIssue (owner, repo, issueNumber) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.update({
owner,
repo,
@@ -181,10 +161,6 @@ async function doOpenIssue (owner, repo, issueNumber) {
};
async function doRemoveAssignees (owner, repo, issueNumber, assignees) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.removeAssignees({
owner,
repo,
@@ -195,10 +171,6 @@ async function doRemoveAssignees (owner, repo, issueNumber, assignees) {
};
async function doSetLabels (owner, repo, issueNumber, labels) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.setLabels({
owner,
repo,
@@ -209,10 +181,6 @@ async function doSetLabels (owner, repo, issueNumber, labels) {
};
async function doUnlockIssue (owner, repo, issueNumber) {
if (core.getInput("body")) {
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
}
await octokit.issues.unlock({
owner,
repo,