8000 Merge pull request #798 from ncino/feat/using-rest-for-push · wagoid/commitlint-github-action@0de1544 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0de1544

Browse files
authored
Merge pull request #798 from ncino/feat/using-rest-for-push
feat: updating push event trigger to use rest API (OctoKit) vs push event
2 parents baa1b23 + c3ab7fd commit 0de1544

File tree

3 files changed

+260
-124
lines changed

3 files changed

+260
-124
lines changed

src/action.mjs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,21 @@ const getCommitDepth = () => {
2222
return Number.isNaN(commitDepth) ? null : Math.max(commitDepth, 0)
2323
}
2424

25-
const getPushEventCommits = () => {
26-
const mappedCommits = eventContext.payload.commits.map((commit) => ({
27-
message: commit.message,
28-
hash: commit.id,
29-
}))
25+
const getPushEventCommits = async () => {
26+
const octokit = getOctokit(getInput('token'))
27+
const { owner, repo } = eventContext.issue
28+
const { before } = eventContext.payload
29+
const { data: commits } = await octokit.rest.repos.listCommits({
30+
owner,
31+
repo,
32+
sha: before,
33+
per_page: 100,
34+
})
3035

31-
return mappedCommits
36+
return commits.map((commit) => ({
37+
message: commit.commit.message,
38+
hash: commit.sha,
39+
}))
3240
}
3341

3442
const getPullRequestEventCommits = async () => {

0 commit comments

Comments
 (0)
0