Skip to content

Commit

Permalink
✨ Support custom GitHub Enterprise Host
Browse files Browse the repository at this point in the history
  • Loading branch information
BetaHuhn committed Mar 3, 2021
1 parent e078d03 commit 18215cb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
20 changes: 16 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30289,7 +30301,7 @@ const parseFiles = (files) => {
}
}

core.wanr('Warn: No source files specified')
core.warn('Warn: No source files specified')
})
}

Expand Down Expand Up @@ -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 }`)
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 13 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }`)
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 18215cb

Please sign in to comment.