mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-20 18:55:47 +08:00
feat: add more
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,7 +1,7 @@
|
|||||||
# @source: https://github.com/xrkffgg/gitignore/blob/master/.gitignore
|
# @source: https://github.com/xrkffgg/gitignore/blob/master/.gitignore
|
||||||
|
|
||||||
# production
|
# production
|
||||||
/dist
|
# /dist
|
||||||
/docs-dist
|
/docs-dist
|
||||||
|
|
||||||
# Log file
|
# Log file
|
||||||
|
205
README.md
205
README.md
@@ -17,17 +17,23 @@ English | [简体中文](./README.zh-CN.md)
|
|||||||
- ⭐ 基 础
|
- ⭐ 基 础
|
||||||
- [`add-assignees`](#add-assignees)
|
- [`add-assignees`](#add-assignees)
|
||||||
- [`add-labels`](#add-labels)
|
- [`add-labels`](#add-labels)
|
||||||
|
- [`close-issue`](#close-issue)
|
||||||
- [`create-comment`](#create-comment)
|
- [`create-comment`](#create-comment)
|
||||||
- [`create-issue`](#create-issue)
|
- [`create-issue`](#create-issue)
|
||||||
- [`delete-comment`](#delete-comment)
|
- [`delete-comment`](#delete-comment)
|
||||||
- [`lock-issue`](#lock-issue)
|
- [`lock-issue`](#lock-issue)
|
||||||
|
- [`open-issue`](#open-issue)
|
||||||
- [`remove-assignees`](#remove-assignees)
|
- [`remove-assignees`](#remove-assignees)
|
||||||
- [`set-labels`](#set-labels)
|
- [`set-labels`](#set-labels)
|
||||||
- [`unlock-issue`](#unlock-issue)
|
- [`unlock-issue`](#unlock-issue)
|
||||||
- [`update-comment`](#update-comment)
|
- [`update-comment`](#update-comment)
|
||||||
- [`update-issue`](#update-issue)
|
- [`update-issue`](#update-issue)
|
||||||
- ⭐ 进 阶
|
- ⭐ 进 阶
|
||||||
|
- [`find-comment`](#find-comments)
|
||||||
- ⭐ 高 级
|
- ⭐ 高 级
|
||||||
|
- 222
|
||||||
|
- 🌰 例 子
|
||||||
|
- [`find-comments + create-comment + update-comment`](#find-comments--create-comment--update-comment)
|
||||||
|
|
||||||
## 🚀 使 用
|
## 🚀 使 用
|
||||||
|
|
||||||
@@ -37,14 +43,14 @@ English | [简体中文](./README.zh-CN.md)
|
|||||||
|
|
||||||
#### `add-assignees`
|
#### `add-assignees`
|
||||||
|
|
||||||
当一个 issue 新增时,将这个 issue 指定某人或多人。
|
当一个 issue 新增或修改时,将这个 issue 指定某人或多人。
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
name: Add Assigness
|
name: Add Assigness
|
||||||
|
|
||||||
on:
|
on:
|
||||||
issues:
|
issues:
|
||||||
types: [opened]
|
types: [opened, edited]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
add-assigness:
|
add-assigness:
|
||||||
@@ -67,8 +73,8 @@ jobs:
|
|||||||
| assignees | 指定人。当不填或者为空字符、空数组时,不指定 | string \| string\[] | ✖ | v1 |
|
| assignees | 指定人。当不填或者为空字符、空数组时,不指定 | string \| string\[] | ✖ | v1 |
|
||||||
|
|
||||||
- 其中的 `name` 可根据自行根据实际情况修改
|
- 其中的 `name` 可根据自行根据实际情况修改
|
||||||
- [on 参考](#触发机制)
|
- [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)。
|
||||||
|
|
||||||
⏫ [返回列表](#列-表)
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
@@ -106,6 +112,29 @@ jobs:
|
|||||||
|
|
||||||
⏫ [返回列表](#列-表)
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
#### `close-issue`
|
||||||
|
|
||||||
|
关闭指定 issue。当输入 `body` 时,会同时进行评论。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
- name: Close issue
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'close-issue'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-number: xxx
|
||||||
|
body: 'This is auto closed.'
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||||
|
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||||
|
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||||
|
| body | 关闭 issue 时,可进行评论 | string | ✖ | v1 |
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
#### `create-comment`
|
#### `create-comment`
|
||||||
|
|
||||||
当新增一个指定 label 时,对该 issue 进行评论。
|
当新增一个指定 label 时,对该 issue 进行评论。
|
||||||
@@ -145,8 +174,8 @@ jobs:
|
|||||||
|
|
||||||
- `body` 默认为:`Currently at ${owner}/${repo}. And this is default comment.`
|
- `body` 默认为:`Currently at ${owner}/${repo}. And this is default comment.`
|
||||||
- 其中 `${owner}/${repo}` 表示当前仓库
|
- 其中 `${owner}/${repo}` 表示当前仓库
|
||||||
- 返回 `comment-id`,可用于之后操作。用法参考
|
- 返回 `comment-id`,可用于之后操作。[用法参考](#输出使用)
|
||||||
- `${{ github.event.issue.user.login }}` 表示该 issue 的创建者。
|
- `${{ github.event.issue.user.login }}` 表示该 issue 的创建者
|
||||||
|
|
||||||
⏫ [返回列表](#列-表)
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
@@ -188,14 +217,14 @@ jobs:
|
|||||||
| contents | 为新增 issue 增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 |
|
| contents | 为新增 issue 增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 |
|
||||||
|
|
||||||
- `title` 默认为:`Default Title`
|
- `title` 默认为:`Default Title`
|
||||||
- `body` 默认同上
|
- `body` 默认值同上
|
||||||
- 返回 `issue_number`,用法同上
|
- 返回 `issue-number`,[用法参考](#输出使用)
|
||||||
|
|
||||||
⏫ [返回列表](#列-表)
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
#### `delete-comment`
|
#### `delete-comment`
|
||||||
|
|
||||||
根据 [`comment_id`](#comment_id-获取) 删除指定评论。单个应用场景不多,可参考高级用法。
|
根据 [`comment_id`](#comment_id-获取) 删除指定评论。
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
- name: Delete comment
|
- name: Delete comment
|
||||||
@@ -246,6 +275,28 @@ jobs:
|
|||||||
|
|
||||||
⏫ [返回列表](#列-表)
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
#### `open-issue`
|
||||||
|
|
||||||
|
打开指定 issue。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
- name: Open issue
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'open-issue'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-number: xxx
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||||
|
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||||
|
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||||
|
| body | 打开 issue 时,可进行评论 | string | ✖ | v1 |
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
#### `remove-assignees`
|
#### `remove-assignees`
|
||||||
|
|
||||||
移除 issue 指定人员。
|
移除 issue 指定人员。
|
||||||
@@ -315,18 +366,28 @@ jobs:
|
|||||||
|
|
||||||
#### `update-comment`
|
#### `update-comment`
|
||||||
|
|
||||||
根据 [`comment_id`](#comment_id-获取) 更新指定评论。单个应用场景不多,可参考高级用法。
|
根据 [`comment_id`](#comment_id-获取) 更新指定评论。
|
||||||
|
|
||||||
|
下面的例子展示的是,为每个新增的 comment 增加 👀 。
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
- name: Update comment
|
name: Add eyes to each comment
|
||||||
uses: actions-cool/issue-helper@v1
|
|
||||||
with:
|
on:
|
||||||
actions: 'update-comment'
|
issue_comment:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
types: [created]
|
||||||
comment-id: xxx
|
|
||||||
body: 'xxxx'
|
jobs:
|
||||||
update-mode: 'replace'
|
update-comment:
|
||||||
contents: '+1'
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Update comment
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'update-comment'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
comment-id: ${{ github.event.comment.id }}
|
||||||
|
contents: 'eyes'
|
||||||
```
|
```
|
||||||
|
|
||||||
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
@@ -338,7 +399,7 @@ jobs:
|
|||||||
| update-mode | 更新模式。`replace` 替换,`append` 附加 | string | ✖ | v1 |
|
| update-mode | 更新模式。`replace` 替换,`append` 附加 | string | ✖ | v1 |
|
||||||
| contents | 为 comment 增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 |
|
| contents | 为 comment 增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 |
|
||||||
|
|
||||||
- `body` 默认同上
|
- `body` 不输入时,会保持原有
|
||||||
- `update-mode` 为 `append` 时,会进行附加操作。非 `append` 都会进行替换。仅对 `body` 生效。
|
- `update-mode` 为 `append` 时,会进行附加操作。非 `append` 都会进行替换。仅对 `body` 生效。
|
||||||
|
|
||||||
⏫ [返回列表](#列-表)
|
⏫ [返回列表](#列-表)
|
||||||
@@ -382,8 +443,93 @@ jobs:
|
|||||||
|
|
||||||
### ⭐ 进 阶
|
### ⭐ 进 阶
|
||||||
|
|
||||||
|
#### `find-comments`
|
||||||
|
|
||||||
|
查找当前仓库 1 号 issue 中,创建者是 k ,内容包含 `this` 的评论列表。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
- name: Find comments
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'find-comments'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-number: 1
|
||||||
|
comment-auth: k
|
||||||
|
body-includes: 'this'
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数 | 描述 | 类型 | 必填 | 版本 |
|
||||||
|
| -- | -- | -- | -- | -- |
|
||||||
|
| actions | actions 类型,当为数组时,会进行多个操作 | string \| string\[] | ✔ | v1 |
|
||||||
|
| token | [token 说明](#token) | string | ✖ | v1 |
|
||||||
|
| issue-number | 指定的 issue | number | ✔ | v1 |
|
||||||
|
| comment-auth | 评论创建者,不填时会查询所有 | string | ✖ | v1 |
|
||||||
|
| body-includes | 评论内容包含过滤,不填时无校验 | string | ✖ | v1 |
|
||||||
|
|
||||||
|
- 返回 `comments`, 格式如下:
|
||||||
|
|
||||||
|
```js
|
||||||
|
[
|
||||||
|
{id: 1, body: 'xxx'},
|
||||||
|
{id: 2, body: 'xxxx'}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
### ⭐ 高 级
|
### ⭐ 高 级
|
||||||
|
|
||||||
|
## 🌰 例 子
|
||||||
|
|
||||||
|
以下列举一些例子,请灵活参考。
|
||||||
|
|
||||||
|
### `find-comments + create-comment + update-comment`
|
||||||
|
|
||||||
|
假设场景:当 issue 修改时,查找是否有 k 创建的包含 `error` 的评论,如果只有一个,则更新该 comment,如果没有,则新增一个 comment。
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
isssue:
|
||||||
|
types: [edited]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
do-test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: find comments
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
id: fcid
|
||||||
|
with:
|
||||||
|
actions: 'find-comments'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-number: ${{ github.event.issue.number }}
|
||||||
|
comment-auth: k
|
||||||
|
body-includes: 'error'
|
||||||
|
|
||||||
|
- name: create comment
|
||||||
|
if: ${{ steps.fcid.outputs.comments.length == 0 }}
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'create-comment'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-number: ${{ github.event.issue.number }}
|
||||||
|
body: 'Some error!'
|
||||||
|
|
||||||
|
- name: update comment
|
||||||
|
if: ${{ steps.fcid.outputs.comments.length == 1 }}
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
with:
|
||||||
|
actions: 'update-comment'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
comment-id: ${{ steps.fcid.outputs.comments[0].id }}
|
||||||
|
body: 'Some error again!'
|
||||||
|
update-mode: 'append'
|
||||||
|
```
|
||||||
|
|
||||||
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
## 🎁 参 考
|
## 🎁 参 考
|
||||||
|
|
||||||
### token
|
### token
|
||||||
@@ -401,12 +547,21 @@ jobs:
|
|||||||
|
|
||||||
⏫ [返回列表](#列-表)
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
### 条件判断
|
### 输出使用
|
||||||
|
```yml
|
||||||
|
- name: Create issue
|
||||||
|
uses: actions-cool/issue-helper@v1
|
||||||
|
id: createissue
|
||||||
|
with:
|
||||||
|
actions: 'create-issue'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Check outputs
|
||||||
|
run: echo "Outputs issue_number is ${{ steps.createissue.outputs.issue-number }}"
|
||||||
|
```
|
||||||
|
### GitHub Docs
|
||||||
|
|
||||||
### 触发机制
|
- [GitHub Actions 语法](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#on)
|
||||||
|
- [工作流触发机制](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows)
|
||||||
- [Workflow syntax for GitHub Actions](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#on)
|
|
||||||
- [Events that trigger workflows](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows)
|
|
||||||
|
|
||||||
⏫ [返回列表](#列-表)
|
⏫ [返回列表](#列-表)
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@ inputs:
|
|||||||
description: 'github_token'
|
description: 'github_token'
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
outputs:
|
outputs:
|
||||||
issue_number:
|
issue-number:
|
||||||
description: 'Create Issue Number'
|
description: 'Create Issue Number'
|
||||||
comment-id:
|
comment-id:
|
||||||
description: 'Create comment ID'
|
description: 'Create comment ID'
|
||||||
|
33
src/advanced.js
Normal file
33
src/advanced.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
require('dotenv').config();
|
||||||
|
const core = require("@actions/core");
|
||||||
|
const { Octokit } = require('@octokit/rest');
|
||||||
|
|
||||||
|
const token = core.getInput('token') || process.env.GH_TOKEN;
|
||||||
|
const octokit = new Octokit({ auth: `token ${token}` });
|
||||||
|
|
||||||
|
const commentAuth = core.getInput("comment-auth") || 'xrkffgg';
|
||||||
|
const bodyIncludes = core.getInput('body-includes') || 'is';
|
||||||
|
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
doFindComments,
|
||||||
|
};
|
50
src/base.js
50
src/base.js
@@ -38,6 +38,20 @@ async function doAddLabels (owner, repo, issueNumber, labels) {
|
|||||||
core.info(`Actions: [add-labels][${labels}] success!`);
|
core.info(`Actions: [add-labels][${labels}] success!`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function doCloseIssue (owner, repo, issueNumber) {
|
||||||
|
if (core.getInput("body")) {
|
||||||
|
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
|
||||||
|
}
|
||||||
|
|
||||||
|
await octokit.issues.update({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
issue_number: issueNumber,
|
||||||
|
state: 'closed'
|
||||||
|
});
|
||||||
|
core.info(`Actions: [close-issue][${issueNumber}] success!`);
|
||||||
|
};
|
||||||
|
|
||||||
async function doCreateComment (owner, repo, issueNumber, body) {
|
async function doCreateComment (owner, repo, issueNumber, body) {
|
||||||
const { data } = await octokit.issues.createComment({
|
const { data } = await octokit.issues.createComment({
|
||||||
owner,
|
owner,
|
||||||
@@ -92,7 +106,7 @@ async function doCreateIssue (owner, repo, title, body, labels, assignees) {
|
|||||||
}
|
}
|
||||||
const { data } = await octokit.issues.create(params);
|
const { data } = await octokit.issues.create(params);
|
||||||
core.info(`Actions: [create-issue][${title}] success!`);
|
core.info(`Actions: [create-issue][${title}] success!`);
|
||||||
core.setOutput("issue_number", data.number);
|
core.setOutput("issue-number", data.number);
|
||||||
|
|
||||||
if (contents) {
|
if (contents) {
|
||||||
await doCreateIssueContent(owner, repo, data.number, contents);
|
await doCreateIssueContent(owner, repo, data.number, contents);
|
||||||
@@ -141,6 +155,20 @@ async function doLockIssue (owner, repo, issueNumber) {
|
|||||||
core.info(`Actions: [lock-issue][${issueNumber}] success!`);
|
core.info(`Actions: [lock-issue][${issueNumber}] success!`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function doOpenIssue (owner, repo, issueNumber) {
|
||||||
|
if (core.getInput("body")) {
|
||||||
|
await doCreateComment(owner, repo, issueNumber, core.getInput("body"))
|
||||||
|
}
|
||||||
|
|
||||||
|
await octokit.issues.update({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
issue_number: issueNumber,
|
||||||
|
state: 'open'
|
||||||
|
});
|
||||||
|
core.info(`Actions: [open-issue][${issueNumber}] success!`);
|
||||||
|
};
|
||||||
|
|
||||||
async function doRemoveAssignees (owner, repo, issueNumber, assignees) {
|
async function doRemoveAssignees (owner, repo, issueNumber, assignees) {
|
||||||
await octokit.issues.removeAssignees({
|
await octokit.issues.removeAssignees({
|
||||||
owner,
|
owner,
|
||||||
@@ -190,14 +218,16 @@ async function doUpdateComment (
|
|||||||
comment_id: commentId
|
comment_id: commentId
|
||||||
};
|
};
|
||||||
|
|
||||||
if (updateMode === 'append') {
|
if (core.getInput("body")) {
|
||||||
params.body = `${comment_body}\n${body}`;
|
if (updateMode === 'append') {
|
||||||
} else {
|
params.body = `${comment_body}\n${body}`;
|
||||||
params.body = body;
|
} else {
|
||||||
}
|
params.body = body;
|
||||||
|
}
|
||||||
|
|
||||||
await octokit.issues.updateComment(params);
|
await octokit.issues.updateComment(params);
|
||||||
core.info(`Actions: [update-comment][${commentId}] success!`);
|
core.info(`Actions: [update-comment][${commentId}] success!`);
|
||||||
|
}
|
||||||
|
|
||||||
if (contents) {
|
if (contents) {
|
||||||
await doCreateCommentContent(owner, repo, commentId, contents);
|
await doCreateCommentContent(owner, repo, commentId, contents);
|
||||||
@@ -280,15 +310,17 @@ function testContent(con) {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
doAddAssignees,
|
doAddAssignees,
|
||||||
doAddLabels,
|
doAddLabels,
|
||||||
|
doCloseIssue,
|
||||||
doCreateComment,
|
doCreateComment,
|
||||||
doCreateCommentContent,
|
doCreateCommentContent,
|
||||||
doCreateIssue,
|
doCreateIssue,
|
||||||
doCreateIssueContent,
|
doCreateIssueContent,
|
||||||
doDeleteComment,
|
doDeleteComment,
|
||||||
doLockIssue,
|
doLockIssue,
|
||||||
|
doOpenIssue,
|
||||||
doRemoveAssignees,
|
doRemoveAssignees,
|
||||||
doSetLabels,
|
doSetLabels,
|
||||||
doUnlockIssue,
|
doUnlockIssue,
|
||||||
|
doUpdateComment,
|
||||||
doUpdateIssue,
|
doUpdateIssue,
|
||||||
doUpdateComment
|
|
||||||
};
|
};
|
||||||
|
45
src/main.js
45
src/main.js
@@ -4,38 +4,53 @@ const github = require("@actions/github");
|
|||||||
const {
|
const {
|
||||||
doAddAssignees,
|
doAddAssignees,
|
||||||
doAddLabels,
|
doAddLabels,
|
||||||
|
doCloseIssue,
|
||||||
doCreateComment,
|
doCreateComment,
|
||||||
doCreateCommentContent,
|
doCreateCommentContent,
|
||||||
doCreateIssue,
|
doCreateIssue,
|
||||||
doCreateIssueContent,
|
doCreateIssueContent,
|
||||||
doDeleteComment,
|
doDeleteComment,
|
||||||
doLockIssue,
|
doLockIssue,
|
||||||
|
doOpenIssue,
|
||||||
doRemoveAssignees,
|
doRemoveAssignees,
|
||||||
doSetLabels,
|
doSetLabels,
|
||||||
doUnlockIssue,
|
doUnlockIssue,
|
||||||
|
doUpdateComment,
|
||||||
doUpdateIssue,
|
doUpdateIssue,
|
||||||
doUpdateComment
|
|
||||||
} = require('./base.js');
|
} = require('./base.js');
|
||||||
|
|
||||||
|
const {
|
||||||
|
doFindComments,
|
||||||
|
} = require('./advanced.js');
|
||||||
|
|
||||||
const ALLACTIONS = [
|
const ALLACTIONS = [
|
||||||
|
// base
|
||||||
'add-assignees',
|
'add-assignees',
|
||||||
'add-labels',
|
'add-labels',
|
||||||
|
'close-issue',
|
||||||
'create-comment',
|
'create-comment',
|
||||||
'create-issue',
|
'create-issue',
|
||||||
'delete-comment',
|
'delete-comment',
|
||||||
'lock-issue',
|
'lock-issue',
|
||||||
|
'open-issue',
|
||||||
'remove-assignees',
|
'remove-assignees',
|
||||||
'set-labels',
|
'set-labels',
|
||||||
'unlock-issue',
|
'unlock-issue',
|
||||||
'update-comment',
|
'update-comment',
|
||||||
'update-issue',
|
'update-issue',
|
||||||
|
|
||||||
|
// advanced
|
||||||
|
'find-comments',
|
||||||
];
|
];
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
try {
|
try {
|
||||||
const owner = github.context.repo.owner;
|
// const owner = github.context.repo.owner;
|
||||||
const repo = github.context.repo.repo;
|
// const repo = github.context.repo.repo;
|
||||||
const issueNumber = core.getInput('issue-number');
|
const owner = 'actions-cool';
|
||||||
|
const repo = 'issue-helper';
|
||||||
|
|
||||||
|
const issueNumber = core.getInput('issue-number') || 1;
|
||||||
const commentId = core.getInput('comment-id');
|
const commentId = core.getInput('comment-id');
|
||||||
|
|
||||||
const defaultBody = `Currently at ${owner}/${repo}. And this is default comment.`
|
const defaultBody = `Currently at ${owner}/${repo}. And this is default comment.`
|
||||||
@@ -54,7 +69,8 @@ async function main() {
|
|||||||
updateMode = 'replace';
|
updateMode = 'replace';
|
||||||
}
|
}
|
||||||
|
|
||||||
const actions = core.getInput("actions", { required: true });
|
// const actions = core.getInput("actions", { required: true });
|
||||||
|
const actions = 'find-comments';
|
||||||
|
|
||||||
if (typeof(actions) === 'object') {
|
if (typeof(actions) === 'object') {
|
||||||
actions.forEach(item => {
|
actions.forEach(item => {
|
||||||
@@ -74,12 +90,16 @@ async function main() {
|
|||||||
|
|
||||||
async function choseActions(action) {
|
async function choseActions(action) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
// base
|
||||||
case 'add-assignees':
|
case 'add-assignees':
|
||||||
await doAddAssignees(owner, repo, issueNumber, assignees);
|
await doAddAssignees(owner, repo, issueNumber, assignees);
|
||||||
break;
|
break;
|
||||||
case 'add-labels':
|
case 'add-labels':
|
||||||
await doAddLabels(owner, repo, issueNumber, labels);
|
await doAddLabels(owner, repo, issueNumber, labels);
|
||||||
break;
|
break;
|
||||||
|
case 'close-issue':
|
||||||
|
await doCloseIssue(owner, repo, issueNumber);
|
||||||
|
break;
|
||||||
case 'create-comment':
|
case 'create-comment':
|
||||||
await doCreateComment(owner, repo, issueNumber, body);
|
await doCreateComment(owner, repo, issueNumber, body);
|
||||||
break;
|
break;
|
||||||
@@ -92,6 +112,9 @@ async function main() {
|
|||||||
case 'lock-issue':
|
case 'lock-issue':
|
||||||
await doLockIssue(owner, repo, issueNumber);
|
await doLockIssue(owner, repo, issueNumber);
|
||||||
break;
|
break;
|
||||||
|
case 'open-issue':
|
||||||
|
await doOpenIssue(owner, repo, issueNumber);
|
||||||
|
break;
|
||||||
case 'remove-assignees':
|
case 'remove-assignees':
|
||||||
await doRemoveAssignees(owner, repo, issueNumber, assignees);
|
await doRemoveAssignees(owner, repo, issueNumber, assignees);
|
||||||
break;
|
break;
|
||||||
@@ -123,6 +146,18 @@ async function main() {
|
|||||||
labels
|
labels
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
// advanced
|
||||||
|
case 'find-comments':
|
||||||
|
await doFindComments(
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
issueNumber
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// ultimate
|
||||||
|
|
||||||
|
// default
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
6
src/ultimate.js
Normal file
6
src/ultimate.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
require('dotenv').config();
|
||||||
|
const core = require("@actions/core");
|
||||||
|
const { Octokit } = require('@octokit/rest');
|
||||||
|
|
||||||
|
const token = core.getInput('token') || process.env.GH_TOKEN;
|
||||||
|
const octokit = new Octokit({ auth: `token ${token}` });
|
Reference in New Issue
Block a user