From 9db31b50eebb05c92ab1cd1c07966047489f74db Mon Sep 17 00:00:00 2001 From: shikajiro Date: Wed, 31 Jan 2024 17:00:58 +0900 Subject: [PATCH] =?UTF-8?q?draft=E3=81=AF=E3=83=AC=E3=83=93=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E4=BE=9D=E9=A0=BC=E3=82=92=E5=87=BA=E3=81=95=E3=81=AA?= =?UTF-8?q?=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/github.ts | 8 ++++++++ src/main.ts | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/domain/github.ts b/src/domain/github.ts index 1d028b6..c94e083 100644 --- a/src/domain/github.ts +++ b/src/domain/github.ts @@ -33,6 +33,14 @@ const buildError = (payload: unknown): Error => { return new Error(`unknown event hook: ${JSON.stringify(payload)}`); }; +export const needToReviewRequest = (payload: WebhookPayload): boolean => { + if (payload.pull_request?.draft === true) { + return false; + } + + return true; +}; + export const needToSendApproveMention = (payload: WebhookPayload): boolean => { if (payload.review?.state === "approved") { return true; diff --git a/src/main.ts b/src/main.ts index 6798c3d..9304e0d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,7 +10,11 @@ import { postError, } from "./usecase"; import { getAllInputs } from "./model"; -import { needToMention, needToSendApproveMention } from "./domain/github"; +import { + needToMention, + needToReviewRequest, + needToSendApproveMention, +} from "./domain/github"; export const main = async (): Promise => { core.info("start main"); @@ -27,7 +31,7 @@ export const main = async (): Promise => { const mapping = await execLoadMapping(configurationPath, repoToken); core.info(JSON.stringify(mapping)); - if (reviewRequest) { + if (reviewRequest && needToReviewRequest(payload)) { await execPrReviewRequestedMention(payload, allInputs, mapping); core.info("finish execPrReviewRequestedMention()"); } else if (needToSendApproveMention(payload)) {