From fa634960b5967fad66d56bd52925966854f4f384 Mon Sep 17 00:00:00 2001 From: Yossi Saadi Date: Sat, 7 Dec 2024 21:56:41 +0200 Subject: [PATCH] feat: handle merge_group event - get squashed commit --- src/action.mjs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/action.mjs b/src/action.mjs index 49d7285..bb979f5 100644 --- a/src/action.mjs +++ b/src/action.mjs @@ -7,6 +7,7 @@ import { format } from '@commitlint/format' import load from '@commitlint/load' import generateOutputs from './generateOutputs.mjs' +const mergeGroupEvent = 'merge_group' const pullRequestEvent = 'pull_request' const pullRequestTargetEvent = 'pull_request_target' const pullRequestEvents = [pullRequestEvent, pullRequestTargetEvent] @@ -65,7 +66,21 @@ const getPullRequestEventCommits = async () => { })) } +const getMergeGroupEventCommits = async () => { + const { merge_group } = eventContext.payload + + return [ + { + message: merge_group.head_commit.message, + hash: merge_group.head_sha, + }, + ] +} + const getEventCommits = async () => { + if (GITHUB_EVENT_NAME === mergeGroupEvent) { + return getMergeGroupEventCommits() + } if (pullRequestEvents.includes(GITHUB_EVENT_NAME)) { return getPullRequestEventCommits() }