This commit is contained in:
xrkffgg
2021-02-02 20:12:42 +08:00
parent f6788d2b8e
commit 1cc6f0b7ca
6 changed files with 124 additions and 8 deletions

View File

@@ -105,6 +105,7 @@ When the following list does not have the features you want, you can submit it i
- [`close-issue`](#close-issue)
- [`create-comment`](#create-comment)
- [`create-issue`](#create-issue)
- [`create-label`](#create-label)
- [`delete-comment`](#delete-comment)
- [`lock-issue`](#lock-issue)
- [`mark-duplicate`](#mark-duplicate)
@@ -319,6 +320,34 @@ jobs:
⏫ [Back to list](#List)
#### `create-label`
Create label。If you want to create multiple labels base on repository path. [See](https://github.com/actions-cool/create-labels).
```yml
- name: Create label
uses: actions-cool/issues-helper@v2.0.0
with:
actions: 'create-label'
token: ${{ secrets.GITHUB_TOKEN }}
label-name: 'xx'
label-color: '0095b3'
label-desc: 'xx'
```
| Param | Desc | Type | Required |
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| label-name | Label name, emoji support | string | ✔ |
| label-color | Label color, the format is hexadecimal color code, without `#` | string | ✖ |
| label-desc | Label description | string | ✖ |
- `label-name`: If it already exists, no operation
- `label-color`: Default is `ededed`
⏫ [Back to list](#List)
#### `delete-comment`
According to [`comment-id`](#comment-id) delete the specified comment.

View File

@@ -105,6 +105,7 @@
- [`close-issue`](#close-issue)
- [`create-comment`](#create-comment)
- [`create-issue`](#create-issue)
- [`create-label`](#create-label)
- [`delete-comment`](#delete-comment)
- [`lock-issue`](#lock-issue)
- [`mark-duplicate`](#mark-duplicate)

30
dist/index.js vendored
View File

@@ -7985,6 +7985,30 @@ async function doCreateIssueContent(owner, repo, issueNumber, contents) {
}
}
async function doCreateLabel(owner, repo) {
const name = core.getInput('label-name');
const color = core.getInput('label-color') || 'ededed';
const description = core.getInput('label-desc') || '';
if (!name) {
core.setFailed(`This actions should input 'label-name'!`);
return false;
}
try {
await octokit.issues.createLabel({
owner,
repo,
name,
color,
description,
});
core.info(`Actions: [create-label][${name}] success!`);
} catch (err) {
console.log(err.message)
}
}
async function doDeleteComment(owner, repo, commentId) {
await octokit.issues.deleteComment({
owner,
@@ -8313,6 +8337,7 @@ module.exports = {
doCreateCommentContent,
doCreateIssue,
doCreateIssueContent,
doCreateLabel,
doDeleteComment,
doMarkDuplicate,
doLockIssue,
@@ -8342,6 +8367,7 @@ const {
doCloseIssue,
doCreateComment,
doCreateIssue,
doCreateLabel,
doDeleteComment,
doMarkDuplicate,
doLockIssue,
@@ -8372,6 +8398,7 @@ const ALLACTIONS = [
'close-issue',
'create-comment',
'create-issue',
'create-label',
'delete-comment',
'lock-issue',
'mark-duplicate',
@@ -8452,6 +8479,9 @@ async function main() {
case 'create-issue':
await doCreateIssue(owner, repo, title, body, labels, assignees);
break;
case 'create-label':
await doCreateLabel(owner, repo);
break;
case 'delete-comment':
await doDeleteComment(owner, repo, commentId);
break;

View File

@@ -183,6 +183,32 @@ jobs:
- `title` default is `Default Title`
- Return `issue-number`. [Usage reference](/en-US/guide/ref#-outputs-use)
## `create-label`
Create label。If you want to create multiple labels base on repository path. [See](https://github.com/actions-cool/create-labels).
```yml
- name: Create label
uses: actions-cool/issues-helper@v2.0.0
with:
actions: 'create-label'
token: ${{ secrets.GITHUB_TOKEN }}
label-name: 'xx'
label-color: '0095b3'
label-desc: 'xx'
```
| Param | Desc | Type | Required |
| -- | -- | -- | -- |
| actions | Action type | string | ✔ |
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ |
| label-name | Label name, emoji support | string | ✔ |
| label-color | Label color, the format is hexadecimal color code, without `#` | string | ✖ |
| label-desc | Label description | string | ✖ |
- `label-name`: If it already exists, no operation
- `label-color`: Default is `ededed`
## `delete-comment`
According to [`comment-id`](/en-US/guide/ref#-comment-id) delete the specified comment.

View File

@@ -183,6 +183,32 @@ jobs:
- `title` 默认为:`Default Title`
- 返回 `issue-number`[用法参考](/guide/ref#-outputs-使用)
## `create-label`
新增 label。若想根据目录生成多个 labels[可查看](https://github.com/actions-cool/create-labels)。
```yml
- name: Create label
uses: actions-cool/issues-helper@v2.0.0
with:
actions: 'create-label'
token: ${{ secrets.GITHUB_TOKEN }}
label-name: 'xx'
label-color: '0095b3'
label-desc: 'xx'
```
| 参数 | 描述 | 类型 | 必填 |
| -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ |
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ |
| label-name | 标签名称,支持 emoji | string | ✔ |
| label-color | 标签颜色,格式为 16 进制色码,不加 `#` | string | ✖ |
| label-desc | 标签描述 | string | ✖ |
- `label-name`:若已存在,则无操作
- `label-color`:默认为 `ededed`
## `delete-comment`
根据 [`comment-id`](/guide/ref#-comment-id) 删除指定评论。

View File

@@ -132,14 +132,18 @@ async function doCreateLabel(owner, repo) {
return false;
}
await octokit.issues.createLabel({
owner,
repo,
name,
color,
description,
});
core.info(`Actions: [create-label][${name}] success!`);
try {
await octokit.issues.createLabel({
owner,
repo,
name,
color,
description,
});
core.info(`Actions: [create-label][${name}] success!`);
} catch (err) {
console.log(err.message)
}
}
async function doDeleteComment(owner, repo, commentId) {