fix: yml not support array (#11)

* fix: yml not support array

* add
This commit is contained in:
xrkffgg
2020-12-24 16:40:07 +08:00
committed by GitHub
parent 1d0bb25b58
commit 822d3a57be
6 changed files with 102 additions and 116 deletions

67
dist/index.js vendored
View File

@@ -6107,15 +6107,7 @@ async function doQueryIssues (owner, repo, labels, state) {
issueMentioned ? params.mentioned = issueMentioned : null;
if (labels) {
if (typeof(labels) === 'string') {
params.labels = labels;
} else {
let temp = '';
labels.forEach((it,index) => {
index == labels.length - 1 ? temp += `${it}` : temp += `${it},`;
});
params.labels = temp;
}
params.labels = labels;
}
const res = await octokit.issues.listForRepo(params);
@@ -6215,12 +6207,12 @@ async function doCreateComment (owner, repo, issueNumber, body) {
core.setOutput("comment-id", data.id);
if (contents) {
await doCreateCommentContent(owner, repo, data.id, contents);
await doCreateCommentContent(owner, repo, data.id, dealInput(contents));
}
};
async function doCreateCommentContent(owner, repo, commentId) {
if (typeof(contents) === 'object') {
async function doCreateCommentContent(owner, repo, commentId, contents) {
if (contents.length) {
contents.forEach(async item => {
if (testContent(item)) {
await octokit.reactions.createForIssueComment({
@@ -6232,14 +6224,6 @@ async function doCreateCommentContent(owner, repo, commentId) {
core.info(`Actions: [create-reactions][${item}] success!`);
}
})
} else if (typeof(contents) === 'string' && testContent(contents)) {
await octokit.reactions.createForIssueComment({
owner,
repo,
comment_id: commentId,
content: contents
});
core.info(`Actions: [create-reactions][${contents}] success!`);
}
};
@@ -6258,12 +6242,12 @@ async function doCreateIssue (owner, repo, title, body, labels, assignees) {
core.setOutput("issue-number", data.number);
if (contents) {
await doCreateIssueContent(owner, repo, data.number, contents);
await doCreateIssueContent(owner, repo, data.number, dealInput(contents));
}
};
async function doCreateIssueContent(owner, repo, issueNumber) {
if (typeof(contents) === 'object') {
async function doCreateIssueContent(owner, repo, issueNumber, contents) {
if (contents.length) {
contents.forEach(async item => {
if (testContent(item)) {
await octokit.reactions.createForIssue({
@@ -6275,14 +6259,6 @@ async function doCreateIssueContent(owner, repo, issueNumber) {
core.info(`Actions: [create-reactions][${item}] success!`);
}
})
} else if (typeof(contents) === 'string' && testContent(contents)) {
await octokit.reactions.createForIssue({
owner,
repo,
issue_number: issueNumber,
content: contents
});
core.info(`Actions: [create-reactions][${contents}] success!`);
}
};
@@ -6375,7 +6351,7 @@ async function doUpdateComment (
}
if (contents) {
await doCreateCommentContent(owner, repo, commentId, contents);
await doCreateCommentContent(owner, repo, commentId, dealInput(contents));
}
};
@@ -6397,8 +6373,20 @@ async function doUpdateIssue (
})
const issue_body = issue.data.body;
const issue_title = issue.data.title;
const issue_labels = issue.data.labels;
const issue_assignees = issue.data.assignees;
let issue_labels = [];
if (issue.data.labels.length > 0) {
issue.data.labels.forEach(it =>{
issue_labels.push(it.name);
});
}
let issue_assignees = [];
if (issue.data.assignees.length > 0) {
issue.data.assignees.forEach(it =>{
issue_assignees.push(it.login);
});
}
let params = {
owner,
@@ -6666,11 +6654,12 @@ main();
function dealInput (para) {
let arr = [];
if (para) {
if (typeof(para) === 'string') {
arr.push(para);
} else {
arr = para;
}
const paraArr = para.split(',');
paraArr.forEach(it => {
if(it.trim()){
arr.push(it.trim())
}
})
}
return arr;
};