diff --git a/dist/index.js b/dist/index.js index 03bd6fc..8bc520a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -901,6 +901,7 @@ class GitHubHelper { if (token) { options.auth = `${token}`; } + options.baseUrl = process.env['GITHUB_API_URL'] || 'https://api.github.com'; this.octokit = new octokit_client_1.Octokit(options); } parseRepository(repository) { @@ -1157,11 +1158,8 @@ exports.getRepoPath = getRepoPath; function getRemoteDetail(remoteUrl) { // 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 githubServerMatch = githubServerUrl.match(/^https?:\/\/(.+)$/i); + const githubUrl = process.env['GITHUB_SERVER_URL'] || 'https://github.com'; + const githubServerMatch = githubUrl.match(/^https?:\/\/(.+)$/i); if (!githubServerMatch) { throw new Error('Could not parse GitHub Server name'); } diff --git a/src/github-helper.ts b/src/github-helper.ts index f031230..db8e015 100644 --- a/src/github-helper.ts +++ b/src/github-helper.ts @@ -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) } diff --git a/src/utils.ts b/src/utils.ts index eb6aeb7..4659b04 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -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') }