diff --git a/dist/index.js b/dist/index.js index 8024b52..b49207d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8005,7 +8005,7 @@ async function doCreateLabel(owner, repo) { }); core.info(`Actions: [create-label][${name}] success!`); } catch (err) { - console.log(err.message) + console.log(err.message); } } @@ -8053,17 +8053,6 @@ async function doMarkDuplicate(owner, repo, labels) { const ifCommandInput = !!duplicateCommand; - 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 ( !commentBody.includes('?') && ((ifCommandInput && @@ -8071,6 +8060,18 @@ 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; + } + if (ifCommandInput) { const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of'); await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true); diff --git a/src/base.js b/src/base.js index dd5185a..97ac1f5 100644 --- a/src/base.js +++ b/src/base.js @@ -190,17 +190,6 @@ async function doMarkDuplicate(owner, repo, labels) { const ifCommandInput = !!duplicateCommand; - 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 ( !commentBody.includes('?') && ((ifCommandInput && @@ -208,6 +197,17 @@ 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; + } + if (ifCommandInput) { const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of'); await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true);