mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-21 19:25:46 +08:00
feat: add create-label
This commit is contained in:
28
README.md
28
README.md
@@ -319,6 +319,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`
|
#### `delete-comment`
|
||||||
|
|
||||||
根据 [`comment-id`](#comment-id) 删除指定评论。
|
根据 [`comment-id`](#comment-id) 删除指定评论。
|
||||||
|
@@ -22,8 +22,16 @@ inputs:
|
|||||||
description: 'Issue assignees'
|
description: 'Issue assignees'
|
||||||
random-to:
|
random-to:
|
||||||
description: 'Issue assignees random to'
|
description: 'Issue assignees random to'
|
||||||
|
# label
|
||||||
labels:
|
labels:
|
||||||
description: 'Issue 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:
|
state:
|
||||||
description: 'Issue state'
|
description: 'Issue state'
|
||||||
update-mode:
|
update-mode:
|
||||||
|
21
src/base.js
21
src/base.js
@@ -122,6 +122,26 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
await octokit.issues.createLabel({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
name,
|
||||||
|
color,
|
||||||
|
description,
|
||||||
|
});
|
||||||
|
core.info(`Actions: [create-label][${name}] success!`);
|
||||||
|
}
|
||||||
|
|
||||||
async function doDeleteComment(owner, repo, commentId) {
|
async function doDeleteComment(owner, repo, commentId) {
|
||||||
await octokit.issues.deleteComment({
|
await octokit.issues.deleteComment({
|
||||||
owner,
|
owner,
|
||||||
@@ -450,6 +470,7 @@ module.exports = {
|
|||||||
doCreateCommentContent,
|
doCreateCommentContent,
|
||||||
doCreateIssue,
|
doCreateIssue,
|
||||||
doCreateIssueContent,
|
doCreateIssueContent,
|
||||||
|
doCreateLabel,
|
||||||
doDeleteComment,
|
doDeleteComment,
|
||||||
doMarkDuplicate,
|
doMarkDuplicate,
|
||||||
doLockIssue,
|
doLockIssue,
|
||||||
|
@@ -8,6 +8,7 @@ const {
|
|||||||
doCloseIssue,
|
doCloseIssue,
|
||||||
doCreateComment,
|
doCreateComment,
|
||||||
doCreateIssue,
|
doCreateIssue,
|
||||||
|
doCreateLabel,
|
||||||
doDeleteComment,
|
doDeleteComment,
|
||||||
doMarkDuplicate,
|
doMarkDuplicate,
|
||||||
doLockIssue,
|
doLockIssue,
|
||||||
@@ -38,6 +39,7 @@ const ALLACTIONS = [
|
|||||||
'close-issue',
|
'close-issue',
|
||||||
'create-comment',
|
'create-comment',
|
||||||
'create-issue',
|
'create-issue',
|
||||||
|
'create-label',
|
||||||
'delete-comment',
|
'delete-comment',
|
||||||
'lock-issue',
|
'lock-issue',
|
||||||
'mark-duplicate',
|
'mark-duplicate',
|
||||||
@@ -118,6 +120,9 @@ async function main() {
|
|||||||
case 'create-issue':
|
case 'create-issue':
|
||||||
await doCreateIssue(owner, repo, title, body, labels, assignees);
|
await doCreateIssue(owner, repo, title, body, labels, assignees);
|
||||||
break;
|
break;
|
||||||
|
case 'create-label':
|
||||||
|
await doCreateLabel(owner, repo);
|
||||||
|
break;
|
||||||
case 'delete-comment':
|
case 'delete-comment':
|
||||||
await doDeleteComment(owner, repo, commentId);
|
await doDeleteComment(owner, repo, commentId);
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user