Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #13 from shikajiro/pr-draft
Browse files Browse the repository at this point in the history
draftはレビュー依頼を出さない
  • Loading branch information
shikajiro authored Jan 31, 2024
2 parents 7ce0aa3 + 9db31b5 commit d3dae36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/domain/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> => {
core.info("start main");
Expand All @@ -27,7 +31,7 @@ export const main = async (): Promise<void> => {
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)) {
Expand Down

0 comments on commit d3dae36

Please sign in to comment.