Skip to content

Commit

Permalink
Support GitHub Enterprise Server
Browse files Browse the repository at this point in the history
* parse GITHUB_SERVER_URL if present
* accept proper server remotes as well
  • Loading branch information
jonico committed Jan 25, 2021
1 parent 171fc6c commit adc6552
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
12 changes: 10 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1157,8 +1157,16 @@ exports.getRepoPath = getRepoPath;
function getRemoteDetail(remoteUrl) {
// Parse the protocol and github repository from a URL
// e.g. HTTPS, peter-evans/create-pull-request
const httpsUrlPattern = /^https:\/\/.*@?github.com\/(.+\/.+)$/i;
const sshUrlPattern = /^[email protected]:(.+\/.+).git$/i;
let githubServerUrl = process.env['GITHUB_SERVER_URL'];
if (!githubServerUrl) {
githubServerUrl = 'https://github.com';
}
const githubServerMatch = githubServerUrl.match(/^https?:\/\/(.+)$/i);
if (!githubServerMatch) {
throw new Error('Could not parse GitHub Server name');
}
const httpsUrlPattern = new RegExp('^https?://.*@?' + githubServerMatch[1] + '/(.+/.+)$', 'i');
const sshUrlPattern = new RegExp('^git@' + githubServerMatch[1] + ':(.+/.+).git$', 'i');
const httpsMatch = remoteUrl.match(httpsUrlPattern);
if (httpsMatch) {
return {
Expand Down
20 changes: 18 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,24 @@ 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
const httpsUrlPattern = /^https:\/\/.*@?github.com\/(.+\/.+)$/i
const sshUrlPattern = /^[email protected]:(.+\/.+).git$/i
let githubServerUrl = process.env['GITHUB_SERVER_URL']
if (!githubServerUrl) {
githubServerUrl = 'https://github.com'
}

const githubServerMatch = githubServerUrl.match(/^https?:\/\/(.+)$/i)
if (!githubServerMatch) {
throw new Error('Could not parse GitHub Server name')
}

const httpsUrlPattern = new RegExp(
'^https?://.*@?' + githubServerMatch[1] + '/(.+/.+)$',
'i'
)
const sshUrlPattern = new RegExp(
'^git@' + githubServerMatch[1] + ':(.+/.+).git$',
'i'
)

const httpsMatch = remoteUrl.match(httpsUrlPattern)
if (httpsMatch) {
Expand Down

0 comments on commit adc6552

Please sign in to comment.