Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/index.js

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,25 @@ async function main() {
}
} else {
const eventObj = await readJson(eventFile)
const commits =
eventObj.commits ||
(await request(eventObj.pull_request._links.commits.href))
const commits = await getEventCommits(eventObj)

if (!commits) {
return setFailed(
'Could not find commits in this workflow event. Run version-check on a push or pull_request event, or use `static-checking` with `file-url` for events such as workflow_dispatch, workflow_call, workflow_run, or release.'
)
}

await processDirectory(dir, commits)
}
}

async function getEventCommits(eventObj) {
if (Array.isArray(eventObj?.commits)) return eventObj.commits

const commitsUrl = eventObj?.pull_request?._links?.commits?.href
if (commitsUrl) return request(commitsUrl)
}

function isURL(str: string) {
try {
new URL(str)
Expand Down