export function isReviewOrCommentHasTrigger()

in src/github/validation/trigger.ts [94:120]


export function isReviewOrCommentHasTrigger(context: JunieExecutionContext, regExp: RegExp) {
    if (
        isPullRequestReviewEvent(context) &&
        (context.eventAction === "submitted" || context.eventAction === "edited")
    ) {
        const reviewBody = context.payload.review.body || "";

        if (regExp.test(reviewBody)) {
            console.log(
                `Pull request review contains exact trigger phrase '${regExp}'`,
            );
            return true;
        }
    }

    if (
        isIssueCommentEvent(context) ||
        isPullRequestReviewCommentEvent(context)
    ) {
        const commentBody = context.payload.comment.body;

        if (regExp.test(commentBody)) {
            console.log(`Comment contains exact trigger phrase '${regExp}'`);
            return true;
        }
    }
}