Adding ability to specify the GitHub Server URL and allowing for it to differ from the Actions workflow host

This commit is contained in:
Peter Murray 2022-09-09 13:05:37 +00:00 committed by GitHub
parent 2541b1294d
commit 385d3aa94f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 182 additions and 62 deletions

23
src/octokit-helper.ts Normal file
View file

@ -0,0 +1,23 @@
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)
}