From 1cc6f0b7ca9d01588767e23d872284f6d32c5f89 Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Tue, 2 Feb 2021 20:12:42 +0800 Subject: [PATCH] add doc --- README.en-US.md | 29 +++++++++++++++++++++++++++++ README.md | 1 + dist/index.js | 30 ++++++++++++++++++++++++++++++ docs/base.en-US.md | 26 ++++++++++++++++++++++++++ docs/base.md | 26 ++++++++++++++++++++++++++ src/base.js | 20 ++++++++++++-------- 6 files changed, 124 insertions(+), 8 deletions(-) diff --git a/README.en-US.md b/README.en-US.md index 0d2905b..96410a6 100644 --- a/README.en-US.md +++ b/README.en-US.md @@ -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. diff --git a/README.md b/README.md index 516a115..c21763f 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/dist/index.js b/dist/index.js index 69800bd..8024b52 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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; diff --git a/docs/base.en-US.md b/docs/base.en-US.md index 7fb11c6..6ae2aa4 100644 --- a/docs/base.en-US.md +++ b/docs/base.en-US.md @@ -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. diff --git a/docs/base.md b/docs/base.md index dc410e5..c59a734 100644 --- a/docs/base.md +++ b/docs/base.md @@ -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) 删除指定评论。 diff --git a/src/base.js b/src/base.js index 83d1910..ca40665 100644 --- a/src/base.js +++ b/src/base.js @@ -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) {