Skip to content

Commit

Permalink
Merge pull request #798 from ncino/feat/using-rest-for-push
Browse files Browse the repository at this point in the history
feat: updating push event trigger to use rest API (OctoKit) vs push event
  • Loading branch information
wagoid authored Aug 20, 2024
2 parents baa1b23 + c3ab7fd commit 0de1544
Show file tree
Hide file tree
Showing 3 changed files with 260 additions and 124 deletions.
20 changes: 14 additions & 6 deletions src/action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@ const getCommitDepth = () => {
return Number.isNaN(commitDepth) ? null : Math.max(commitDepth, 0)
}

const getPushEventCommits = () => {
const mappedCommits = eventContext.payload.commits.map((commit) => ({
message: commit.message,
hash: commit.id,
}))
const getPushEventCommits = async () => {
const octokit = getOctokit(getInput('token'))
const { owner, repo } = eventContext.issue
const { before } = eventContext.payload
const { data: commits } = await octokit.rest.repos.listCommits({
owner,
repo,
sha: before,
per_page: 100,
})

return mappedCommits
return commits.map((commit) => ({
message: commit.commit.message,
hash: commit.sha,
}))
}

const getPullRequestEventCommits = async () => {
Expand Down
Loading

0 comments on commit 0de1544

Please sign in to comment.