From 18215cb3de5f5951b98289c01750fb0321c45ec6 Mon Sep 17 00:00:00 2001 From: BetaHuhn Date: Wed, 3 Mar 2021 19:03:41 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Support=20custom=20GitHub=20Enterpr?= =?UTF-8?q?ise=20Host?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/index.js | 20 ++++++++++++++++---- src/config.js | 14 +++++++++++++- src/git.js | 2 +- src/index.js | 2 +- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/dist/index.js b/dist/index.js index 5f31539e..1902911f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -30257,12 +30257,24 @@ core.debug( ) const parseRepoName = (fullRepo) => { + let host = 'github.com' + + if (fullRepo.startsWith('http')) { + const url = new URL(fullRepo) + host = url.host + + fullRepo = url.pathname.replace(/^\/+/, '') // Remove leading slash + + core.info('Using custom host') + } + const user = fullRepo.split('/')[0] const name = fullRepo.split('/')[1].split('@')[0] const branch = fullRepo.split('/')[1].split('@')[1] || 'default' return { - fullName: `${ user }/${ name }`, + fullName: `${ host }/${ user }/${ name }`, + host, user, name, branch @@ -30289,7 +30301,7 @@ const parseFiles = (files) => { } } - core.wanr('Warn: No source files specified') + core.warn('Warn: No source files specified') }) } @@ -30375,7 +30387,7 @@ const { const init = (repo) => { const localPath = path.join(TMP_DIR, repo.fullName) - const gitUrl = `https://${ GITHUB_TOKEN }@github.com/${ repo.fullName }.git` + const gitUrl = `https://${ GITHUB_TOKEN }@${ repo.fullName }.git` const clone = () => { core.info(`Cloning ${ repo.fullName } into ${ localPath }`) @@ -30578,7 +30590,7 @@ const run = async () => { core.info(`Repository Info`) core.info(`Slug : ${ item.repo.name }`) core.info(`Owner : ${ item.repo.user }`) - core.info(`Https Url : https://github.com/${ item.repo.fullName }`) + core.info(`Https Url : https://${ item.repo.fullName }`) core.info(`Branch : ${ item.repo.branch }`) core.info(' ') try { diff --git a/src/config.js b/src/config.js index a29b4cb8..35a9a466 100644 --- a/src/config.js +++ b/src/config.js @@ -97,12 +97,24 @@ core.debug( ) const parseRepoName = (fullRepo) => { + let host = 'github.com' + + if (fullRepo.startsWith('http')) { + const url = new URL(fullRepo) + host = url.host + + fullRepo = url.pathname.replace(/^\/+/, '') // Remove leading slash + + core.info('Using custom host') + } + const user = fullRepo.split('/')[0] const name = fullRepo.split('/')[1].split('@')[0] const branch = fullRepo.split('/')[1].split('@')[1] || 'default' return { - fullName: `${ user }/${ name }`, + fullName: `${ host }/${ user }/${ name }`, + host, user, name, branch diff --git a/src/git.js b/src/git.js index 0a845bd5..4a64d4b3 100644 --- a/src/git.js +++ b/src/git.js @@ -15,7 +15,7 @@ const { const init = (repo) => { const localPath = path.join(TMP_DIR, repo.fullName) - const gitUrl = `https://${ GITHUB_TOKEN }@github.com/${ repo.fullName }.git` + const gitUrl = `https://${ GITHUB_TOKEN }@${ repo.fullName }.git` const clone = () => { core.info(`Cloning ${ repo.fullName } into ${ localPath }`) diff --git a/src/index.js b/src/index.js index cca9c6c1..c920f648 100644 --- a/src/index.js +++ b/src/index.js @@ -28,7 +28,7 @@ const run = async () => { core.info(`Repository Info`) core.info(`Slug : ${ item.repo.name }`) core.info(`Owner : ${ item.repo.user }`) - core.info(`Https Url : https://github.com/${ item.repo.fullName }`) + core.info(`Https Url : https://${ item.repo.fullName }`) core.info(`Branch : ${ item.repo.branch }`) core.info(' ') try {