diff --git a/dist/index.js b/dist/index.js index b49207d..9a49cb3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8060,49 +8060,52 @@ async function doMarkDuplicate(owner, repo, labels) { commentBody.split(' ')[0] == duplicateCommand) || testDuplicate(commentBody)) ) { + try { + const res = await octokit.repos.getCollaboratorPermissionLevel({ + owner, + repo, + username: commentUser, + }); + const { permission } = res.data; + if (!checkPermission(requirePermission, permission)) { + core.info(`The user ${commentUser} is not allow!`); + return false; + } - const res = await octokit.repos.getCollaboratorPermissionLevel({ - owner, - repo, - username: commentUser, - }); - const { permission } = res.data; - if (!checkPermission(requirePermission, permission)) { - core.info(`The user ${commentUser} is not allow!`); - return false; - } + if (ifCommandInput) { + const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of'); + await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true); + } else if (contents) { + await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents)); + } - if (ifCommandInput) { - const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of'); - await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true); - } else if (contents) { - await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents)); - } + const issue = await octokit.issues.get({ + owner, + repo, + issue_number: issueNumber, + }); + let newLabels = []; + if (issue.data.labels.length > 0) { + newLabels = issue.data.labels + .map(({ name }) => name) + .filter(name => !dealStringToArr(removeLables).includes(name)); + } + if (duplicateLabels) { + newLabels = [...newLabels, ...dealStringToArr(duplicateLabels)]; + } + if (labels) { + newLabels = dealStringToArr(labels); + } + if (newLabels.length > 0) { + await doSetLabels(owner, repo, issueNumber, newLabels.toString()); + core.info(`Actions: [mark-duplicate-labels][${newLabels}] success!`); + } - const issue = await octokit.issues.get({ - owner, - repo, - issue_number: issueNumber, - }); - let newLabels = []; - if (issue.data.labels.length > 0) { - newLabels = issue.data.labels - .map(({ name }) => name) - .filter(name => !dealStringToArr(removeLables).includes(name)); - } - if (duplicateLabels) { - newLabels = [...newLabels, ...dealStringToArr(duplicateLabels)]; - } - if (labels) { - newLabels = dealStringToArr(labels); - } - if (newLabels.length > 0) { - await doSetLabels(owner, repo, issueNumber, newLabels.toString()); - core.info(`Actions: [mark-duplicate-labels][${newLabels}] success!`); - } - - if (closeIssue == 'true') { - await doCloseIssue(owner, repo, issueNumber); + if (closeIssue == 'true') { + await doCloseIssue(owner, repo, issueNumber); + } + } catch (error) { + core.info(error.message); } } else { core.info( diff --git a/src/base.js b/src/base.js index 97ac1f5..d07ca59 100644 --- a/src/base.js +++ b/src/base.js @@ -197,48 +197,52 @@ async function doMarkDuplicate(owner, repo, labels) { commentBody.split(' ')[0] == duplicateCommand) || testDuplicate(commentBody)) ) { - const res = await octokit.repos.getCollaboratorPermissionLevel({ - owner, - repo, - username: commentUser, - }); - const { permission } = res.data; - if (!checkPermission(requirePermission, permission)) { - core.info(`The user ${commentUser} is not allow!`); - return false; - } + try { + const res = await octokit.repos.getCollaboratorPermissionLevel({ + owner, + repo, + username: commentUser, + }); + const { permission } = res.data; + if (!checkPermission(requirePermission, permission)) { + core.info(`The user ${commentUser} is not allow!`); + return false; + } - if (ifCommandInput) { - const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of'); - await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true); - } else if (contents) { - await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents)); - } + if (ifCommandInput) { + const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of'); + await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true); + } else if (contents) { + await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents)); + } - const issue = await octokit.issues.get({ - owner, - repo, - issue_number: issueNumber, - }); - let newLabels = []; - if (issue.data.labels.length > 0) { - newLabels = issue.data.labels - .map(({ name }) => name) - .filter(name => !dealStringToArr(removeLables).includes(name)); - } - if (duplicateLabels) { - newLabels = [...newLabels, ...dealStringToArr(duplicateLabels)]; - } - if (labels) { - newLabels = dealStringToArr(labels); - } - if (newLabels.length > 0) { - await doSetLabels(owner, repo, issueNumber, newLabels.toString()); - core.info(`Actions: [mark-duplicate-labels][${newLabels}] success!`); - } + const issue = await octokit.issues.get({ + owner, + repo, + issue_number: issueNumber, + }); + let newLabels = []; + if (issue.data.labels.length > 0) { + newLabels = issue.data.labels + .map(({ name }) => name) + .filter(name => !dealStringToArr(removeLables).includes(name)); + } + if (duplicateLabels) { + newLabels = [...newLabels, ...dealStringToArr(duplicateLabels)]; + } + if (labels) { + newLabels = dealStringToArr(labels); + } + if (newLabels.length > 0) { + await doSetLabels(owner, repo, issueNumber, newLabels.toString()); + core.info(`Actions: [mark-duplicate-labels][${newLabels}] success!`); + } - if (closeIssue == 'true') { - await doCloseIssue(owner, repo, issueNumber); + if (closeIssue == 'true') { + await doCloseIssue(owner, repo, issueNumber); + } + } catch (error) { + core.info(error.message); } } else { core.info(