mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-22 11:45:48 +08:00
feat: add random to (#35)
* feat: add random to * add actions * up * up version * add less
This commit is contained in:
38
src/base.js
38
src/base.js
@@ -20,7 +20,8 @@ const {
|
||||
} = require('./public.js');
|
||||
|
||||
const {
|
||||
dealInput,
|
||||
dealStringToArr,
|
||||
dealRandomAssignees,
|
||||
testDuplicate,
|
||||
} = require('./util.js');
|
||||
|
||||
@@ -31,15 +32,18 @@ const context = github.context;
|
||||
|
||||
const contents = core.getInput("contents");
|
||||
|
||||
const randomTo = core.getInput("random-to");
|
||||
|
||||
// **************************************************************************
|
||||
async function doAddAssignees (owner, repo, issueNumber, assignees) {
|
||||
const arr = dealRandomAssignees(assignees, randomTo);
|
||||
await octokit.issues.addAssignees({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issueNumber,
|
||||
assignees: dealInput(assignees)
|
||||
assignees: arr
|
||||
});
|
||||
core.info(`Actions: [add-assignees][${assignees}] success!`);
|
||||
core.info(`Actions: [add-assignees][${arr}] success!`);
|
||||
};
|
||||
|
||||
async function doAddLabels (owner, repo, issueNumber, labels) {
|
||||
@@ -47,7 +51,7 @@ async function doAddLabels (owner, repo, issueNumber, labels) {
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issueNumber,
|
||||
labels: dealInput(labels)
|
||||
labels: dealStringToArr(labels)
|
||||
});
|
||||
core.info(`Actions: [add-labels][${labels}] success!`);
|
||||
};
|
||||
@@ -73,7 +77,7 @@ async function doCreateComment (owner, repo, issueNumber, body) {
|
||||
core.setOutput("comment-id", data.id);
|
||||
|
||||
if (contents) {
|
||||
await doCreateCommentContent(owner, repo, data.id, dealInput(contents));
|
||||
await doCreateCommentContent(owner, repo, data.id, dealStringToArr(contents));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -99,8 +103,8 @@ async function doCreateIssue (owner, repo, title, body, labels, assignees) {
|
||||
repo,
|
||||
title,
|
||||
body,
|
||||
labels: dealInput(labels),
|
||||
assignees: dealInput(assignees),
|
||||
labels: dealStringToArr(labels),
|
||||
assignees: dealRandomAssignees(assignees, randomTo),
|
||||
};
|
||||
|
||||
const { data } = await octokit.issues.create(params);
|
||||
@@ -108,7 +112,7 @@ async function doCreateIssue (owner, repo, title, body, labels, assignees) {
|
||||
core.setOutput("issue-number", data.number);
|
||||
|
||||
if (contents) {
|
||||
await doCreateIssueContent(owner, repo, data.number, dealInput(contents));
|
||||
await doCreateIssueContent(owner, repo, data.number, dealStringToArr(contents));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -160,7 +164,7 @@ async function doMarkDuplicate (owner, repo, labels) {
|
||||
const duplicateLabels = core.getInput("duplicate-labels");
|
||||
const removeLables = core.getInput("remove-labels");
|
||||
const closeIssue = core.getInput("close-issue");
|
||||
|
||||
|
||||
const commentId = context.payload.comment.id;
|
||||
const commentBody = context.payload.comment.body;
|
||||
const issueNumber = context.payload.issue.number;
|
||||
@@ -172,7 +176,7 @@ async function doMarkDuplicate (owner, repo, labels) {
|
||||
const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of');
|
||||
await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true);
|
||||
} else if (contents) {
|
||||
await doCreateCommentContent(owner, repo, commentId, dealInput(contents));
|
||||
await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents));
|
||||
}
|
||||
if (duplicateLabels) {
|
||||
await doAddLabels(owner, repo, issueNumber, duplicateLabels);
|
||||
@@ -206,7 +210,7 @@ async function doRemoveAssignees (owner, repo, issueNumber, assignees) {
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issueNumber,
|
||||
assignees: dealInput(assignees),
|
||||
assignees: dealStringToArr(assignees)
|
||||
});
|
||||
core.info(`Actions: [remove-assignees][${assignees}] success!`);
|
||||
};
|
||||
@@ -217,7 +221,7 @@ async function doRemoveLabels (owner, repo, issueNumber, labels) {
|
||||
repo,
|
||||
issue_number: issueNumber
|
||||
});
|
||||
const dealLabels = dealInput(labels);
|
||||
const dealLabels = dealStringToArr(labels);
|
||||
let addLables = [];
|
||||
if (dealLabels.length) {
|
||||
issue.data.labels.forEach(item => {
|
||||
@@ -238,7 +242,7 @@ async function doSetLabels (owner, repo, issueNumber, labels) {
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issueNumber,
|
||||
labels: dealInput(labels)
|
||||
labels: dealStringToArr(labels)
|
||||
});
|
||||
core.info(`Actions: [set-labels][${labels}] success!`);
|
||||
};
|
||||
@@ -285,7 +289,7 @@ async function doUpdateComment (
|
||||
}
|
||||
|
||||
if (contents) {
|
||||
await doCreateCommentContent(owner, repo, commentId, dealInput(contents));
|
||||
await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -343,8 +347,8 @@ async function doUpdateIssue (
|
||||
}
|
||||
params.body = next_body;
|
||||
|
||||
params.labels = labels ? dealInput(labels) : issue_labels;
|
||||
params.assignees = assignees ? dealInput(assignees) : issue_assignees;
|
||||
params.labels = labels ? dealStringToArr(labels) : issue_labels;
|
||||
params.assignees = assignees ? dealStringToArr(assignees) : issue_assignees;
|
||||
|
||||
await octokit.issues.update(params);
|
||||
core.info(`Actions: [update-issue][${issueNumber}] success!`);
|
||||
@@ -381,7 +385,7 @@ async function doWelcome (owner, repo, assignees, labels, body) {
|
||||
}
|
||||
|
||||
if (issueContents) {
|
||||
await doCreateIssueContent(owner, repo, issueNumber, dealInput(issueContents));
|
||||
await doCreateIssueContent(owner, repo, issueNumber, dealStringToArr(issueContents));
|
||||
}
|
||||
} else {
|
||||
core.info(`Actions: [welcome][${auth}] is not first time!`);
|
||||
|
Reference in New Issue
Block a user