Support GitHub Server API URL

* pass GitHub Server API in Octokkit constructor
This commit is contained in:
Johannes Nicolai 2021-01-25 19:16:19 +01:00
parent adc6552966
commit 05bc46786e
3 changed files with 6 additions and 10 deletions

View file

@ -23,6 +23,7 @@ export class GitHubHelper {
if (token) {
options.auth = `${token}`
}
options.baseUrl = process.env['GITHUB_API_URL'] || 'https://api.github.com'
this.octokit = new Octokit(options)
}

View file

@ -39,12 +39,9 @@ interface RemoteDetail {
export function getRemoteDetail(remoteUrl: string): RemoteDetail {
// Parse the protocol and github repository from a URL
// e.g. HTTPS, peter-evans/create-pull-request
let githubServerUrl = process.env['GITHUB_SERVER_URL']
if (!githubServerUrl) {
githubServerUrl = 'https://github.com'
}
const githubUrl = process.env['GITHUB_SERVER_URL'] || 'https://github.com'
const githubServerMatch = githubServerUrl.match(/^https?:\/\/(.+)$/i)
const githubServerMatch = githubUrl.match(/^https?:\/\/(.+)$/i)
if (!githubServerMatch) {
throw new Error('Could not parse GitHub Server name')
}