Files
dependency-review-action/src/dependency-graph.ts
Federico Builes 3f943b86c9 initial commit
2022-03-31 18:31:39 +02:00

32 lines
767 B
TypeScript

import * as core from '@actions/core'
import * as githubUtils from '@actions/github/lib/utils'
import * as retry from '@octokit/plugin-retry'
import {Changes, ChangesSchema} from './schemas'
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry)
const octo = new retryingOctokit(
githubUtils.getOctokitOptions(core.getInput('repo-token', {required: true}))
)
export async function compare({
owner,
repo,
baseRef,
headRef
}: {
owner: string
repo: string
baseRef: string
headRef: string
}): Promise<Changes> {
const changes = await octo.paginate(
'GET /repos/{owner}/{repo}/dependency-graph/compare/{basehead}',
{
owner,
repo,
basehead: `${baseRef}...${headRef}`
}
)
return ChangesSchema.parse(changes)
}