From 80e7ea9acc6c0b9e9cd1da02be7ba47257d6c28d Mon Sep 17 00:00:00 2001 From: Tomoya Kashifuku Date: Wed, 6 Mar 2024 00:00:39 +0900 Subject: [PATCH] move threshold to options --- dist/index.js | 7 ++++--- src/main.ts | 3 +-- src/option.ts | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dist/index.js b/dist/index.js index 503592d..a81902c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -29027,7 +29027,7 @@ const uniqueStringArray = (texts) => { */ async function run() { try { - const { token, prNumber } = (0, option_1.getOption)(); + const { token, prNumber, threshold } = (0, option_1.getOption)(); const octokit = (0, github_1.getOctokit)(token); const owner = github_1.context.repo.owner; const repo = github_1.context.repo.repo; @@ -29043,7 +29043,6 @@ async function run() { pull_number: prNumber })).data.filter(c => c.user.type !== 'Bot'); const hasMessageSent = comments.some(comment => comment.body?.includes('It seems the discussion is dragging on.')); - const threshold = Number(core.getInput('threshold', { required: true })); const commentCount = comments.length + reviewComments.length; if (commentCount < threshold) { return; @@ -29103,9 +29102,11 @@ function getOption() { if (isNaN(prNumber) || prNumber === 0) { (0, core_1.setFailed)('pr number is not set properly'); } + const threshold = Number((0, core_1.getInput)('threshold', { required: true })); return { token, - prNumber + prNumber, + threshold }; } exports.getOption = getOption; diff --git a/src/main.ts b/src/main.ts index 449323f..aa4a362 100644 --- a/src/main.ts +++ b/src/main.ts @@ -23,7 +23,7 @@ const uniqueStringArray = (texts: string[]): string[] => { */ export async function run(): Promise { try { - const { token, prNumber } = getOption() + const { token, prNumber, threshold } = getOption() const octokit = getOctokit(token) const owner = context.repo.owner @@ -50,7 +50,6 @@ export async function run(): Promise { const hasMessageSent = comments.some(comment => comment.body?.includes('It seems the discussion is dragging on.') ) - const threshold = Number(core.getInput('threshold', { required: true })) const commentCount = comments.length + reviewComments.length if (commentCount < threshold) { return diff --git a/src/option.ts b/src/option.ts index 6042850..ddf5073 100644 --- a/src/option.ts +++ b/src/option.ts @@ -4,6 +4,7 @@ import { context } from '@actions/github' type Option = { token: string prNumber: number + threshold: number } function getPrNumber(): number { @@ -24,8 +25,11 @@ export function getOption(): Option { setFailed('pr number is not set properly') } + const threshold = Number(getInput('threshold', { required: true })) + return { token, - prNumber + prNumber, + threshold } }