Skip to content

Commit

Permalink
Support GitHub Server API URL
Browse files Browse the repository at this point in the history
* pass GitHub Server API in Octokkit constructor
  • Loading branch information
jonico committed Jan 25, 2021
1 parent adc6552 commit 05bc467
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions dist/index.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
}
Expand Down
1 change: 1 addition & 0 deletions src/github-helper.ts
Expand Up @@ -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)
}

Expand Down
7 changes: 2 additions & 5 deletions src/utils.ts
Expand Up @@ -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')
}
Expand Down

0 comments on commit 05bc467

Please sign in to comment.