5
0
Fork 0
mirror of https://github.com/wagoid/commitlint-github-action.git synced 2025-11-07 16:06:56 +00:00

feat: handle merge_group event - get squashed commit

This commit is contained in:
Yossi Saadi 2024-12-07 21:56:41 +02:00
parent 3d28780bbf
commit fa634960b5

View file

@ -7,6 +7,7 @@ import { format } from '@commitlint/format'
import load from '@commitlint/load' import load from '@commitlint/load'
import generateOutputs from './generateOutputs.mjs' import generateOutputs from './generateOutputs.mjs'
const mergeGroupEvent = 'merge_group'
const pullRequestEvent = 'pull_request' const pullRequestEvent = 'pull_request'
const pullRequestTargetEvent = 'pull_request_target' const pullRequestTargetEvent = 'pull_request_target'
const pullRequestEvents = [pullRequestEvent, pullRequestTargetEvent] 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 () => { const getEventCommits = async () => {
if (GITHUB_EVENT_NAME === mergeGroupEvent) {
return getMergeGroupEventCommits()
}
if (pullRequestEvents.includes(GITHUB_EVENT_NAME)) { if (pullRequestEvents.includes(GITHUB_EVENT_NAME)) {
return getPullRequestEventCommits() return getPullRequestEventCommits()
} }