mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-19 18:25:58 +08:00
done
This commit is contained in:
223
README.md
223
README.md
@@ -29,7 +29,10 @@ English | [简体中文](./README.zh-CN.md)
|
||||
- [`update-comment`](#update-comment)
|
||||
- [`update-issue`](#update-issue)
|
||||
- ⭐ 进 阶
|
||||
- [`check-inactive`](#check-inactive)
|
||||
- [`close-issues`](#close-issues)
|
||||
- [`find-comments`](#find-comments)
|
||||
- [`lock-issues`](#lock-issues)
|
||||
- 🌰 例 子
|
||||
- [`find-comments + create-comment + update-comment`](#find-comments--create-comment--update-comment)
|
||||
|
||||
@@ -66,9 +69,10 @@ jobs:
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||
| assignees | 指定人。当不填或者为空字符、空数组时,不指定 | string \| string\[] | ✖ | v1 |
|
||||
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
|
||||
|
||||
- 其中的 `name` 可根据自行根据实际情况修改
|
||||
- [on 参考](#github-docs)
|
||||
@@ -104,15 +108,16 @@ jobs:
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||
| labels | 新增的 labels。当不填或者为空字符、空数组时,不新增 | string \| string\[] | ✖ | v1 |
|
||||
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
|
||||
#### `close-issue`
|
||||
|
||||
关闭指定 issue。当输入 `body` 时,会同时进行评论。
|
||||
关闭指定 issue。
|
||||
|
||||
```yml
|
||||
- name: Close issue
|
||||
@@ -127,9 +132,9 @@ jobs:
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||
| body | 关闭 issue 时,可进行评论 | string | ✖ | v1 |
|
||||
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
|
||||
@@ -165,14 +170,14 @@ jobs:
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||
| body | 新增评论的内容 | string | ✖ | v1 |
|
||||
| contents | 为新增评论的增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 |
|
||||
|
||||
- `body` 默认为:`Currently at ${owner}/${repo}. And this is default comment.`
|
||||
- 其中 `${owner}/${repo}` 表示当前仓库
|
||||
- 返回 `comment-id`,可用于之后操作。[用法参考](#输出使用)
|
||||
- 返回 `comment-id`,可用于之后操作。[用法参考](#outputs-使用)
|
||||
- `${{ github.event.issue.user.login }}` 表示该 issue 的创建者
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
@@ -207,7 +212,7 @@ jobs:
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| title | 新增 issue 的标题 | string | ✖ | v1 |
|
||||
| body | 新增 issue 的内容 | string | ✖ | v1 |
|
||||
| labels | 为新增 issue 添加 labels | string \| string\[] | ✖ | v1 |
|
||||
@@ -216,13 +221,13 @@ jobs:
|
||||
|
||||
- `title` 默认为:`Default Title`
|
||||
- `body` 默认值同上
|
||||
- 返回 `issue-number`,[用法参考](#输出使用)
|
||||
- 返回 `issue-number`,[用法参考](#outputs-使用)
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
|
||||
#### `delete-comment`
|
||||
|
||||
根据 [`comment_id`](#comment_id-获取) 删除指定评论。
|
||||
根据 [`comment-id`](#comment-id-获取) 删除指定评论。
|
||||
|
||||
```yml
|
||||
- name: Delete comment
|
||||
@@ -236,7 +241,7 @@ jobs:
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| comment-id | 指定的 comment | number | ✔ | v1 |
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
@@ -268,8 +273,9 @@ jobs:
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
|
||||
@@ -289,9 +295,9 @@ jobs:
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||
| body | 打开 issue 时,可进行评论 | string | ✖ | v1 |
|
||||
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
|
||||
@@ -312,15 +318,16 @@ jobs:
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||
| assignees | 移除的指定人。当不填或者为空字符、空数组时,不进行移除 | string \| string\[] | ✖ | v1 |
|
||||
| assignees | 移除的指定人。当为空字符、空数组时,不进行移除 | string \| string\[] | ✔ | v1 |
|
||||
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
|
||||
#### `set-labels`
|
||||
|
||||
设置 issue 的 labels。
|
||||
替换 issue 的 labels。
|
||||
|
||||
```yml
|
||||
- name: Set labels
|
||||
@@ -335,9 +342,10 @@ jobs:
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||
| labels | labels 设置。当不填或者为空字符、空数组时,会移除所有 | string \| string\[] | ✖ | v1 |
|
||||
| labels | labels 设置。当空字符、空数组时,会移除所有 | string \| string\[] | ✔ | v1 |
|
||||
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
|
||||
@@ -357,14 +365,15 @@ jobs:
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||
| body | 解锁 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
|
||||
#### `update-comment`
|
||||
|
||||
根据 [`comment_id`](#comment_id-获取) 更新指定评论。
|
||||
根据 [`comment-id`](#comment-id-获取) 更新指定评论。
|
||||
|
||||
下面的例子展示的是,为每个新增的 comment 增加 👀 。
|
||||
|
||||
@@ -391,11 +400,11 @@ jobs:
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| comment-id | 指定的 comment | number | ✔ | v1 |
|
||||
| body | 更新 comment 的内容 | string | ✖ | v1 |
|
||||
| update-mode | 更新模式。`replace` 替换,`append` 附加 | string | ✖ | v1 |
|
||||
| contents | 为 comment 增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 |
|
||||
| update-mode | 更新模式。默认 `replace` 替换,`append` 附加, | string | ✖ | v1 |
|
||||
| contents | 增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 |
|
||||
|
||||
- `body` 不输入时,会保持原有
|
||||
- `update-mode` 为 `append` 时,会进行附加操作。非 `append` 都会进行替换。仅对 `body` 生效。
|
||||
@@ -425,14 +434,15 @@ jobs:
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||
| state | 修改 issue 的状态,可选值 `open` `closed` | string | ✖ | v1 |
|
||||
| title | 修改 issue 的标题 | string | ✖ | v1 |
|
||||
| body | 修改 issue 的内容 | string | ✖ | v1 |
|
||||
| labels | 修改 issue 的 labels | string \| string\[] | ✖ | v1 |
|
||||
| assignees | 修改 issue 的 assignees | string \| string\[] | ✖ | v1 |
|
||||
| contents | 为修改的 issue 增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 |
|
||||
| update-mode | 更新模式。默认 `replace` 替换,`append` 附加 | string | ✖ | v1 |
|
||||
| labels | 替换 issue 的 labels | string \| string\[] | ✖ | v1 |
|
||||
| assignees | 替换 issue 的 assignees | string \| string\[] | ✖ | v1 |
|
||||
| contents | 增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 |
|
||||
|
||||
- `state` 默认为 `open`
|
||||
- 当可选项不填时,会保持原有
|
||||
@@ -441,6 +451,93 @@ jobs:
|
||||
|
||||
### ⭐ 进 阶
|
||||
|
||||
#### `check-inactive`
|
||||
|
||||
每月 1 号 UTC 0 时,对所有 30 天以上未活跃的 issues 增加 `inactive` 标签。
|
||||
|
||||
```yml
|
||||
name: Check inactive
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 1 * *"
|
||||
|
||||
jobs:
|
||||
check-inactive:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: check-inactive
|
||||
uses: actions-cool/issue-helper@v1
|
||||
with:
|
||||
actions: 'check-inactive'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
inactive-day: 30
|
||||
```
|
||||
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
|
||||
| labels | 标签筛选 | string \| string\[] | ✖ | v1 |
|
||||
| issue-state | 状态筛选 | string | ✖ | v1 |
|
||||
| issue-assignee | 指定人筛选 | string | ✖ | v1 |
|
||||
| issue-creator | 创建人筛选 | string | ✖ | v1 |
|
||||
| issue-mentioned | 提及人筛选 | string | ✖ | v1 |
|
||||
| body-includes | 包含内容筛选 | string | ✖ | v1 |
|
||||
| title-includes | 包含标题筛选 | string | ✖ | v1 |
|
||||
| inactive-day | 非活跃天数筛选 | number | ✖ | v1 |
|
||||
| inactive-label | 新增标签名称 | string | ✖ | v1 |
|
||||
|
||||
- `labels`:为多个时,会查询同时拥有多个。不输入时,会查询所有
|
||||
- `issue-state`:默认为 `all`。可选值 `open` `closed`,非这 2 项时,均为 `all`
|
||||
- `issue-assignee`:不支持多人。不输入或输入 * 时,查询所有。输入 `none` 会查询未添加指定人的 issues
|
||||
- `inactive-day`:当输入时,会筛选 issue 更新时间早于当前时间减去非活跃天数。不输入时,会查询所有
|
||||
- `inactive-label`:默认为 `inactive`,可自定义其他。当项目未包含该 label 时,会自动新建
|
||||
|
||||
#### `close-issues`
|
||||
|
||||
每 7 天 UTC 0 时,关闭已填加 `need info` label 并 7 天以上未活跃的 issues。
|
||||
|
||||
```yml
|
||||
name: Check need info
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 */7 * *"
|
||||
|
||||
jobs:
|
||||
check-need-info:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: close-issues
|
||||
uses: actions-cool/issue-helper@v1
|
||||
with:
|
||||
actions: 'close-issues'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
labels: 'need info'
|
||||
inactive-day: 7
|
||||
```
|
||||
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
|
||||
| labels | 标签筛选 | string \| string\[] | ✖ | v1 |
|
||||
| issue-assignee | 指定人筛选 | string | ✖ | v1 |
|
||||
| issue-creator | 创建人筛选 | string | ✖ | v1 |
|
||||
| issue-mentioned | 提及人筛选 | string | ✖ | v1 |
|
||||
| body-includes | 包含内容筛选 | string | ✖ | v1 |
|
||||
| title-includes | 包含标题筛选 | string | ✖ | v1 |
|
||||
| inactive-day | 非活跃天数筛选 | number | ✖ | v1 |
|
||||
|
||||
- `labels`:为多个时,会查询同时拥有多个。不输入时,会查询所有
|
||||
- `issue-assignee`:不支持多人。不输入或输入 * 时,查询所有。输入 `none` 会查询未添加指定人的 issues
|
||||
- `inactive-day`:当输入时,会筛选 issue 更新时间早于当前时间减去非活跃天数。不输入时,会查询所有
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
|
||||
#### `find-comments`
|
||||
|
||||
查找当前仓库 1 号 issue 中,创建者是 k ,内容包含 `this` 的评论列表。
|
||||
@@ -452,36 +549,85 @@ jobs:
|
||||
actions: 'find-comments'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-number: 1
|
||||
comment-auth: k
|
||||
comment-auth: 'k'
|
||||
body-includes: 'this'
|
||||
```
|
||||
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||
| comment-auth | 评论创建者,不填时会查询所有 | string | ✖ | v1 |
|
||||
| body-includes | 评论内容包含过滤,不填时无校验 | string | ✖ | v1 |
|
||||
| direction | 返回 `comments` 排序 | string | ✖ | v1 |
|
||||
|
||||
- 返回 `comments`, 格式如下:
|
||||
- 返回 `comments`,格式如下:
|
||||
|
||||
```js
|
||||
[
|
||||
{id: 1, body: 'xxx'},
|
||||
{id: 2, body: 'xxxx'}
|
||||
{id: 1, auth: 'x', body: 'xxx', created: '', updated: ''},
|
||||
{id: 2, auth: 'x', body: 'xxx', created: '', updated: ''},
|
||||
]
|
||||
```
|
||||
|
||||
- `direction` 默认为升序,只有设置 `desc` 时,会返回降序
|
||||
- 返回数组中 `created` `updated`,由所处环境决定,会是 UTC +0
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
|
||||
#### `lock-issues`
|
||||
|
||||
每 3 个月 1 号 UTC 0 时,锁定已填加 `inactive` label,并 128 天以上未活跃的所有 issues。
|
||||
|
||||
```yml
|
||||
name: Lock inactive issues
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 1 */3 *"
|
||||
|
||||
jobs:
|
||||
lock-issues:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: lock-issues
|
||||
uses: actions-cool/issue-helper@v1
|
||||
with:
|
||||
actions: 'lock-issues'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
labels: 'inactive'
|
||||
inactive-day: 128
|
||||
```
|
||||
|
||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||
| -- | -- | -- | -- | -- |
|
||||
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||
| token | [token 说明](#token) | string | ✔ | v1 |
|
||||
| body | 操作 issue 时,可进行评论。不输入时,不评论 | string | ✖ | v1 |
|
||||
| labels | 标签筛选 | string \| string\[] | ✖ | v1 |
|
||||
| issue-state | 状态筛选 | string | ✖ | v1 |
|
||||
| issue-assignee | 指定人筛选 | string | ✖ | v1 |
|
||||
| issue-creator | 创建人筛选 | string | ✖ | v1 |
|
||||
| issue-mentioned | 提及人筛选 | string | ✖ | v1 |
|
||||
| body-includes | 包含内容筛选 | string | ✖ | v1 |
|
||||
| title-includes | 包含标题筛选 | string | ✖ | v1 |
|
||||
| inactive-day | 非活跃天数筛选 | number | ✖ | v1 |
|
||||
|
||||
- `labels`:为多个时,会查询同时拥有多个。不输入时,会查询所有
|
||||
- `issue-state`:默认为 `all`。可选值 `open` `closed`,非这 2 项时,均为 `all`
|
||||
- `issue-assignee`:不支持多人。不输入或输入 * 时,查询所有。输入 `none` 会查询未添加指定人的 issues
|
||||
- `inactive-day`:当输入时,会筛选 issue 更新时间早于当前时间减去非活跃天数。不输入时,会查询所有
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
|
||||
## 🌰 例 子
|
||||
|
||||
以下列举一些例子,请灵活参考。
|
||||
灵活参考。
|
||||
|
||||
### `find-comments + create-comment + update-comment`
|
||||
|
||||
假设场景:当 issue 修改时,查找是否有 k 创建的包含 `error` 的评论,如果只有一个,则更新该 comment,如果没有,则新增一个 comment。
|
||||
假设场景:当添加了 `watch` label 的 issue 修改时,查找是否有 k 创建的包含 `error` 的评论,如果只有一个,则更新该 comment,如果没有,则新增一个 comment。
|
||||
|
||||
```yml
|
||||
name: Test
|
||||
@@ -493,6 +639,7 @@ on:
|
||||
jobs:
|
||||
do-test:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.label.name == 'watch'
|
||||
steps:
|
||||
- name: find comments
|
||||
uses: actions-cool/issue-helper@v1
|
||||
@@ -539,7 +686,7 @@ jobs:
|
||||
- `Name` 与 actions 中保持一致
|
||||
- `Value` 填写刚才个人申请的 token
|
||||
|
||||
当 actions 不填写 token 时,会默认为 github-actions <kbd>bot</kbd>。适度使用。
|
||||
当 actions 不填写 token 时,会默认为 github-actions <kbd>bot</kbd>。
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
|
||||
@@ -578,7 +725,7 @@ jobs:
|
||||
|
||||
⏫ [返回列表](#列-表)
|
||||
|
||||
### `comment_id` 获取
|
||||
### `comment-id` 获取
|
||||
|
||||
点击某个评论右上角 `···` 图标,选择 `Copy link`,url 末尾数字即是 `comment_id`。
|
||||
|
||||
@@ -586,6 +733,8 @@ jobs:
|
||||
|
||||
## 💖 谁在使用?
|
||||
|
||||
欢迎在[ **这里** ](https://github.com/actions-cool/issue-helper/issues/6)留言。
|
||||
|
||||
## LICENSE
|
||||
|
||||
[MIT](https://github.com/actions-cool/issue-helper/blob/main/LICENSE)
|
||||
|
46
action.yml
46
action.yml
@@ -5,14 +5,56 @@ branding:
|
||||
icon: 'message-square'
|
||||
color: 'blue'
|
||||
inputs:
|
||||
github_token:
|
||||
description: 'github_token'
|
||||
actions:
|
||||
description: 'Action name'
|
||||
token:
|
||||
description: 'Github_token'
|
||||
default: ${{ github.token }}
|
||||
issue-number:
|
||||
description: 'Issue-number'
|
||||
comment-id:
|
||||
description: 'Comment-id'
|
||||
body:
|
||||
description: 'Issue body'
|
||||
title:
|
||||
description: 'Issue title'
|
||||
assignees:
|
||||
description: 'Issue assignees'
|
||||
labels:
|
||||
description: 'Issue labels'
|
||||
state:
|
||||
description: 'Issue state'
|
||||
update-mode:
|
||||
description: 'Body update mode'
|
||||
contents:
|
||||
description: 'Issue reactions emoji'
|
||||
direction:
|
||||
description: 'Find comments direction'
|
||||
comment-auth:
|
||||
description: 'Find comments query auth'
|
||||
body-includes:
|
||||
description: 'Query use'
|
||||
title-includes:
|
||||
description: 'Query use'
|
||||
issue-creator:
|
||||
description: 'Query use'
|
||||
issue-assignee:
|
||||
description: 'Query use'
|
||||
issue-mentioned:
|
||||
description: 'Query use'
|
||||
issue-state:
|
||||
description: 'Query use'
|
||||
inactive-day:
|
||||
description: 'Query use'
|
||||
inactive-label:
|
||||
description: 'Issue label set use'
|
||||
outputs:
|
||||
issue-number:
|
||||
description: 'Create Issue Number'
|
||||
comment-id:
|
||||
description: 'Create comment ID'
|
||||
comments:
|
||||
description: 'Find comments'
|
||||
runs:
|
||||
using: node12
|
||||
main: 'dist/index.js'
|
||||
|
6862
dist/index.js
vendored
Normal file
6862
dist/index.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -3,10 +3,9 @@
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"description": "Some operations on issue.",
|
||||
"main": "lib/main.js",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"package": "ncc build --source-map"
|
||||
"package": "ncc build src/main.js -o dist"
|
||||
},
|
||||
"author": "xrkffgg",
|
||||
"license": "MIT",
|
||||
@@ -23,7 +22,8 @@
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/github": "^4.0.0",
|
||||
"@octokit/rest": "^18.0.12"
|
||||
"@octokit/rest": "^18.0.12",
|
||||
"dayjs": "^1.9.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "^0.25.1",
|
||||
|
147
src/advanced.js
147
src/advanced.js
@@ -2,22 +2,113 @@ require('dotenv').config();
|
||||
const core = require("@actions/core");
|
||||
const { Octokit } = require('@octokit/rest');
|
||||
|
||||
const token = core.getInput('token') || process.env.GH_TOKEN;
|
||||
var dayjs = require('dayjs');
|
||||
var utc = require('dayjs/plugin/utc');
|
||||
dayjs.extend(utc);
|
||||
var isSameOrBefore = require('dayjs/plugin/isSameOrBefore');
|
||||
dayjs.extend(isSameOrBefore);
|
||||
|
||||
const {
|
||||
doAddLabels,
|
||||
doCloseIssue,
|
||||
doLockIssue
|
||||
} = require('./base.js');
|
||||
|
||||
const token = core.getInput('token');
|
||||
const octokit = new Octokit({ auth: `token ${token}` });
|
||||
|
||||
const commentAuth = core.getInput("comment-auth") || 'xrkffgg';
|
||||
const bodyIncludes = core.getInput('body-includes') || 'is';
|
||||
const titleIncludes = core.getInput('title-includes') || 'test';
|
||||
let direction = core.getInput("direction");
|
||||
direction = direction === 'desc' ? 'desc' : 'asc';
|
||||
|
||||
const issueCreator = core.getInput("issue-creator") || 'xrkffgg';
|
||||
const commentAuth = core.getInput("comment-auth");
|
||||
const bodyIncludes = core.getInput('body-includes');
|
||||
const titleIncludes = core.getInput('title-includes');
|
||||
|
||||
const issueCreator = core.getInput("issue-creator");
|
||||
const issueAssignee = core.getInput('issue-assignee');
|
||||
const issueMentioned = core.getInput('issue-mentioned');
|
||||
|
||||
let issueState = core.getInput("issue-state") || 'all';
|
||||
|
||||
if (issueState != 'open' && issueState != 'closed') {
|
||||
issueState = 'all';
|
||||
}
|
||||
|
||||
const inactiveDay = core.getInput("inactive-day");
|
||||
const inactiveLabel = core.getInput("inactive-label") || 'inactive';
|
||||
|
||||
async function doCheckInactive (owner, repo, labels) {
|
||||
const issues = await doQueryIssues(owner, repo, labels, issueState);
|
||||
|
||||
if (issues.length) {
|
||||
for (let i = 0; i < issues.length; i++) {
|
||||
if (!JSON.stringify(issues[i].labels).includes(inactiveLabel)) {
|
||||
await doAddLabels(owner, repo, issues[i].number, inactiveLabel);
|
||||
} else {
|
||||
core.info(`Actions: [add-inactive] issue ${issues[i].number} has label!`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
core.info(`Actions: [query-issues] empty!`);
|
||||
}
|
||||
};
|
||||
|
||||
async function doCloseIssues (owner, repo, labels) {
|
||||
const issues = await doQueryIssues(owner, repo, labels, 'open');
|
||||
|
||||
if (issues.length) {
|
||||
for (let i = 0; i < issues.length; i++) {
|
||||
await doCloseIssue(owner, repo, issues[i].number);
|
||||
}
|
||||
} else {
|
||||
core.info(`Actions: [query-issues] empty!`);
|
||||
}
|
||||
};
|
||||
|
||||
async function doFindComments (owner, repo, issueNumber) {
|
||||
const res = await octokit.issues.listComments({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issueNumber
|
||||
});
|
||||
core.info(`Actions: [find-comments][${issueNumber}] success!`);
|
||||
let comments = [];
|
||||
res.data.forEach(item => {
|
||||
const a = commentAuth ? item.user.login === commentAuth : true;
|
||||
const b = bodyIncludes ? item.body.includes(bodyIncludes) : true;
|
||||
if (a && b) {
|
||||
comments.push({
|
||||
id: item.id,
|
||||
auth: item.user.login,
|
||||
body: item.body,
|
||||
created: item.created_at,
|
||||
updated: item.updated_at
|
||||
})
|
||||
if (direction === 'desc') {
|
||||
comments.reverse();
|
||||
}
|
||||
}
|
||||
})
|
||||
core.setOutput("comments", comments);
|
||||
};
|
||||
|
||||
async function doLockIssues (owner, repo, labels) {
|
||||
const issues = await doQueryIssues(owner, repo, labels, issueState);
|
||||
|
||||
if (issues.length) {
|
||||
for (let i = 0; i < issues.length; i++) {
|
||||
await doLockIssue(owner, repo, issues[i].number);
|
||||
}
|
||||
} else {
|
||||
core.info(`Actions: [query-issues] empty!`);
|
||||
}
|
||||
};
|
||||
|
||||
async function doQueryIssues (owner, repo, labels, state) {
|
||||
let params = {
|
||||
owner,
|
||||
repo,
|
||||
state: 'open',
|
||||
state,
|
||||
};
|
||||
|
||||
issueCreator ? params.creator = issueCreator : null;
|
||||
@@ -31,46 +122,34 @@ async function doCloseIssues (owner, repo, labels) {
|
||||
let temp = '';
|
||||
labels.forEach((it,index) => {
|
||||
index == labels.length - 1 ? temp += `${it}` : temp += `${it},`;
|
||||
})
|
||||
});
|
||||
params.labels = temp;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(params.labels)
|
||||
|
||||
const res = await octokit.issues.listForRepo(params);
|
||||
console.log(res);
|
||||
let issues = [];
|
||||
for (let i = 0; i < res.data.length; i++) {
|
||||
wip
|
||||
res.data.forEach(iss => {
|
||||
const a = bodyIncludes ? iss.body.includes(bodyIncludes) : true;
|
||||
const b = titleIncludes ? iss.title.includes(titleIncludes) : true;
|
||||
if (a && b) {
|
||||
if (inactiveDay && typeof(inactiveDay) === 'number') {
|
||||
let lastTime = dayjs.utc().subtract(inactiveDay, 'day');
|
||||
if (iss.updated_at.isSameOrBefore(lastTime)) {
|
||||
issues.push(iss);
|
||||
}
|
||||
} else {
|
||||
issues.push(iss);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
async function doFindComments (owner, repo, issueNumber) {
|
||||
const res = await octokit.issues.listComments({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issueNumber
|
||||
});
|
||||
core.info(`Actions: [find-comments][${issueNumber}] success!`);
|
||||
let comments = [];
|
||||
res.data.forEach(item => {
|
||||
if ((commentAuth ? item.user.login === commentAuth : true) && (bodyIncludes ? item.body.includes(bodyIncludes) : true)) {
|
||||
comments.push({
|
||||
id: item.id,
|
||||
body: item.body
|
||||
})
|
||||
}
|
||||
})
|
||||
core.setOutput("comments", comments);
|
||||
|
||||
return issues;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
doCheckInactive,
|
||||
doCloseIssues,
|
||||
doFindComments,
|
||||
doLockIssues,
|
||||
};
|
||||
|
58
src/base.js
58
src/base.js
@@ -13,27 +13,37 @@ const ALLREACTIONS = [
|
||||
"eyes",
|
||||
];
|
||||
|
||||
const token = core.getInput('token') || process.env.GH_TOKEN;
|
||||
const { dealInput } = require('./util.js');
|
||||
|
||||
const token = core.getInput('token');
|
||||
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,
|
||||
issue_number: issueNumber,
|
||||
assignees
|
||||
assignees: dealInput(assignees)
|
||||
});
|
||||
core.info(`Actions: [add-assignees][${assignees}] success!`);
|
||||
};
|
||||
|
||||
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,
|
||||
issue_number: issueNumber,
|
||||
labels
|
||||
labels: dealInput(labels)
|
||||
});
|
||||
core.info(`Actions: [add-labels][${labels}] success!`);
|
||||
};
|
||||
@@ -97,13 +107,10 @@ async function doCreateIssue (owner, repo, title, body, labels, assignees) {
|
||||
repo,
|
||||
title,
|
||||
body,
|
||||
labels
|
||||
labels: dealInput(labels),
|
||||
assignees: dealInput(assignees),
|
||||
};
|
||||
if (typeof(assignees) === 'string') {
|
||||
params.assignees.push(assignees);
|
||||
} else {
|
||||
params.assignees = assignees;
|
||||
}
|
||||
|
||||
const { data } = await octokit.issues.create(params);
|
||||
core.info(`Actions: [create-issue][${title}] success!`);
|
||||
core.setOutput("issue-number", data.number);
|
||||
@@ -147,6 +154,10 @@ 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,
|
||||
@@ -170,26 +181,38 @@ 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,
|
||||
issue_number: issueNumber,
|
||||
assignees
|
||||
assignees: dealInput(assignees),
|
||||
});
|
||||
core.info(`Actions: [remove-assignees][${assignees}] success!`);
|
||||
};
|
||||
|
||||
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,
|
||||
issue_number: issueNumber,
|
||||
labels
|
||||
labels: dealInput(labels)
|
||||
});
|
||||
core.info(`Actions: [set-labels][${labels}] success!`);
|
||||
};
|
||||
|
||||
async function doUnlockIssue (owner, repo, issueNumber) {
|
||||
if (core.getInput("body")) {
|
||||
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
|
||||
}
|
||||
|
||||
await octokit.issues.unlock({
|
||||
owner,
|
||||
repo,
|
||||
@@ -276,17 +299,8 @@ async function doUpdateIssue (
|
||||
}
|
||||
params.body = next_body;
|
||||
|
||||
if (core.getInput("assignees")) {
|
||||
if (typeof(assignees) === 'string') {
|
||||
params.assignees.push(assignees);
|
||||
} else {
|
||||
params.assignees = assignees;
|
||||
}
|
||||
} else {
|
||||
params.assignees = issue_assignees;
|
||||
}
|
||||
|
||||
params.labels = labels ? labels : issue_labels;
|
||||
params.labels = labels ? dealInput(labels) : issue_labels;
|
||||
params.assignees = assignees ? dealInput(assignees) : issue_assignees;
|
||||
|
||||
await octokit.issues.update(params);
|
||||
core.info(`Actions: [update-issue][${issueNumber}] success!`);
|
||||
|
33
src/main.js
33
src/main.js
@@ -20,8 +20,10 @@ const {
|
||||
} = require('./base.js');
|
||||
|
||||
const {
|
||||
doCheckInactive,
|
||||
doCloseIssues,
|
||||
doFindComments,
|
||||
doLockIssues,
|
||||
} = require('./advanced.js');
|
||||
|
||||
const ALLACTIONS = [
|
||||
@@ -41,6 +43,7 @@ const ALLACTIONS = [
|
||||
'update-issue',
|
||||
|
||||
// advanced
|
||||
'check-inactive',
|
||||
'close-issues',
|
||||
'find-comments',
|
||||
'lock-issues',
|
||||
@@ -48,12 +51,10 @@ const ALLACTIONS = [
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
// const owner = github.context.repo.owner;
|
||||
// const repo = github.context.repo.repo;
|
||||
const owner = 'actions-cool';
|
||||
const repo = 'issue-helper';
|
||||
const owner = github.context.repo.owner;
|
||||
const repo = github.context.repo.repo;
|
||||
|
||||
const issueNumber = core.getInput('issue-number') || 1;
|
||||
const issueNumber = core.getInput('issue-number');
|
||||
const commentId = core.getInput('comment-id');
|
||||
|
||||
const defaultBody = `Currently at ${owner}/${repo}. And this is default comment.`
|
||||
@@ -64,16 +65,15 @@ async function main() {
|
||||
|
||||
const assignees = core.getInput("assignees");
|
||||
|
||||
const labels = core.getInput("labels") || ['test'];
|
||||
const labels = core.getInput("labels");
|
||||
const state = core.getInput("state") || 'open';
|
||||
|
||||
let updateMode = core.getInput("update-mode") || 'replace';
|
||||
let updateMode = core.getInput("update-mode");
|
||||
if (updateMode !== 'append') {
|
||||
updateMode = 'replace';
|
||||
}
|
||||
|
||||
// const actions = core.getInput("actions", { required: true });
|
||||
const actions = 'close-issues';
|
||||
const actions = core.getInput("actions", { required: true });
|
||||
|
||||
if (typeof(actions) === 'object') {
|
||||
actions.forEach(item => {
|
||||
@@ -151,6 +151,13 @@ async function main() {
|
||||
break;
|
||||
|
||||
// advanced
|
||||
case 'check-inactive':
|
||||
await doCheckInactive(
|
||||
owner,
|
||||
repo,
|
||||
labels
|
||||
)
|
||||
break;
|
||||
case 'close-issues':
|
||||
await doCloseIssues(
|
||||
owner,
|
||||
@@ -165,7 +172,13 @@ async function main() {
|
||||
issueNumber
|
||||
);
|
||||
break;
|
||||
|
||||
case 'lock-issues':
|
||||
await doLockIssues(
|
||||
owner,
|
||||
repo,
|
||||
labels
|
||||
);
|
||||
break;
|
||||
// default
|
||||
default:
|
||||
break;
|
||||
|
15
src/util.js
Normal file
15
src/util.js
Normal file
@@ -0,0 +1,15 @@
|
||||
function dealInput (para) {
|
||||
let arr = [];
|
||||
if (para) {
|
||||
if (typeof(para) === 'string') {
|
||||
arr.push(para);
|
||||
} else {
|
||||
arr = para;
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
dealInput,
|
||||
};
|
Reference in New Issue
Block a user