Skip to content

Commit 73812a8

Browse files
committed
feat: handle merge_group event - get squashed commit
1 parent 3d28780 commit 73812a8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/action.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { format } from '@commitlint/format'
77
import load from '@commitlint/load'
88
import generateOutputs from './generateOutputs.mjs'
99

10+
const mergeGroupEvent = 'merge_group'
1011
const pullRequestEvent = 'pull_request'
1112
const pullRequestTargetEvent = 'pull_request_target'
1213
const pullRequestEvents = [pullRequestEvent, pullRequestTargetEvent]
@@ -65,7 +66,30 @@ const getPullRequestEventCommits = async () => {
6566
}))
6667
}
6768

69+
const getMergeGroupEventCommits = async () => {
70+
const { merge_group } = eventContext.payload
71+
72+
if (
73+
!merge_group ||
74+
!merge_group.head_commit ||
75+
!merge_group.head_commit.message ||
76+
!merge_group.head_sha
77+
) {
78+
throw new Error('Invalid merge group data in event payload.')
79+
}
80+
81+
return [
82+
{
83+
message: merge_group.head_commit.message,
84+
hash: merge_group.head_sha,
85+
},
86+
]
87+
}
88+
6889
const getEventCommits = async () => {
90+
if (GITHUB_EVENT_NAME === mergeGroupEvent) {
91+
return getMergeGroupEventCommits()
92+
}
6993
if (pullRequestEvents.includes(GITHUB_EVENT_NAME)) {
7094
return getPullRequestEventCommits()
7195
}

0 commit comments

Comments
 (0)