feat: add create-label

This commit is contained in:
xrkffgg
2021-02-02 17:55:54 +08:00
parent 8acd7991df
commit f6788d2b8e
4 changed files with 62 additions and 0 deletions

View File

@@ -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) {
await octokit.issues.deleteComment({
owner,
@@ -450,6 +470,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;