You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
564 B
TypeScript
24 lines
564 B
TypeScript
2 years ago
|
import * as github from '@actions/github'
|
||
|
import {Octokit} from '@octokit/rest'
|
||
|
import {getServerApiUrl} from './url-helper'
|
||
|
|
||
|
// Centralize all Octokit references by re-exporting
|
||
|
export {Octokit} from '@octokit/rest'
|
||
|
|
||
|
export type OctokitOptions = {
|
||
|
baseUrl?: string
|
||
|
userAgent?: string
|
||
|
}
|
||
|
|
||
|
export function getOctokit(authToken: string, opts: OctokitOptions) {
|
||
|
const options: Octokit.Options = {
|
||
|
baseUrl: getServerApiUrl(opts.baseUrl)
|
||
|
}
|
||
|
|
||
|
if (opts.userAgent) {
|
||
|
options.userAgent = opts.userAgent
|
||
|
}
|
||
|
|
||
|
return new github.GitHub(authToken, options)
|
||
|
}
|