feat: add create-label (#54)

* feat: add create-label

* add doc

* format

* add
This commit is contained in:
xrkffgg
2021-02-02 20:33:00 +08:00
committed by GitHub
9 changed files with 181 additions and 2 deletions

View File

@@ -2,3 +2,4 @@ dist/
lib/
docs-dist/
node_modules/
src/.umi/

View File

@@ -6,8 +6,8 @@
[![](https://img.shields.io/badge/marketplace-issues--helper-red?style=flat-square)](https://github.com/marketplace/actions/issues-helper)
[![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![](https://img.shields.io/github/v/release/actions-cool/issues-helper?style=flat-square&color=orange)](https://github.com/actions-cool/issues-helper/releases)
[![](https://img.shields.io/github/v/release/actions-cool/issues-helper?style=flat-square&color=orange)](https://github.com/actions-cool/issues-helper/releases)
[![](https://img.shields.io/github/stars/actions-cool/issues-helper?style=flat-square)](https://github.com/actions-cool/issues-helper/stargazers)
[![](https://img.shields.io/badge/discussions-on%20github-blue?style=flat-square&color=%2308979c)](https://github.com/actions-cool/issues-helper/discussions)
[![](https://img.shields.io/github/license/actions-cool/issues-helper?style=flat-square)](https://github.com/actions-cool/issues-helper/blob/main/LICENSE)
@@ -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

@@ -6,8 +6,8 @@
[![](https://img.shields.io/badge/marketplace-issues--helper-red?style=flat-square)](https://github.com/marketplace/actions/issues-helper)
[![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![](https://img.shields.io/github/v/release/actions-cool/issues-helper?style=flat-square&color=orange)](https://github.com/actions-cool/issues-helper/releases)
[![](https://img.shields.io/github/v/release/actions-cool/issues-helper?style=flat-square&color=orange)](https://github.com/actions-cool/issues-helper/releases)
[![](https://img.shields.io/github/stars/actions-cool/issues-helper?style=flat-square)](https://github.com/actions-cool/issues-helper/stargazers)
[![](https://img.shields.io/badge/discussions-on%20github-blue?style=flat-square&color=%2308979c)](https://github.com/actions-cool/issues-helper/discussions)
[![](https://img.shields.io/github/license/actions-cool/issues-helper?style=flat-square)](https://github.com/actions-cool/issues-helper/blob/main/LICENSE)
@@ -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)
@@ -319,6 +320,34 @@ jobs:
⏫ [返回列表](#列-表)
#### `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 说明](#token) | string | ✔ |
| label-name | 标签名称,支持 emoji | string | ✔ |
| label-color | 标签颜色,格式为 16 进制色码,不加 `#` | string | ✖ |
| label-desc | 标签描述 | string | ✖ |
- `label-name`:若已存在,则无操作
- `label-color`:默认为 `ededed`
⏫ [返回列表](#列-表)
#### `delete-comment`
根据 [`comment-id`](#comment-id) 删除指定评论。

View File

@@ -22,8 +22,16 @@ inputs:
description: 'Issue assignees'
random-to:
description: 'Issue assignees random to'
# label
labels:
description: 'Issue labels'
label-name:
description: 'Create label name'
label-color:
description: 'Create label color, default #ededed'
label-desc:
description: 'Create label description'
state:
description: 'Issue state'
update-mode:

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

@@ -122,6 +122,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,
@@ -450,6 +474,7 @@ module.exports = {
doCreateCommentContent,
doCreateIssue,
doCreateIssueContent,
doCreateLabel,
doDeleteComment,
doMarkDuplicate,
doLockIssue,

View File

@@ -8,6 +8,7 @@ const {
doCloseIssue,
doCreateComment,
doCreateIssue,
doCreateLabel,
doDeleteComment,
doMarkDuplicate,
doLockIssue,
@@ -38,6 +39,7 @@ const ALLACTIONS = [
'close-issue',
'create-comment',
'create-issue',
'create-label',
'delete-comment',
'lock-issue',
'mark-duplicate',
@@ -118,6 +120,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;