Skip to content

Commit 18215cb

Browse files
committed
✨ Support custom GitHub Enterprise Host
1 parent e078d03 commit 18215cb

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

dist/index.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -30257,12 +30257,24 @@ core.debug(
3025730257
)
3025830258

3025930259
const parseRepoName = (fullRepo) => {
30260+
let host = 'github.com'
30261+
30262+
if (fullRepo.startsWith('http')) {
30263+
const url = new URL(fullRepo)
30264+
host = url.host
30265+
30266+
fullRepo = url.pathname.replace(/^\/+/, '') // Remove leading slash
30267+
30268+
core.info('Using custom host')
30269+
}
30270+
3026030271
const user = fullRepo.split('/')[0]
3026130272
const name = fullRepo.split('/')[1].split('@')[0]
3026230273
const branch = fullRepo.split('/')[1].split('@')[1] || 'default'
3026330274

3026430275
return {
30265-
fullName: `${ user }/${ name }`,
30276+
fullName: `${ host }/${ user }/${ name }`,
30277+
host,
3026630278
user,
3026730279
name,
3026830280
branch
@@ -30289,7 +30301,7 @@ const parseFiles = (files) => {
3028930301
}
3029030302
}
3029130303

30292-
core.wanr('Warn: No source files specified')
30304+
core.warn('Warn: No source files specified')
3029330305
})
3029430306
}
3029530307

@@ -30375,7 +30387,7 @@ const {
3037530387
const init = (repo) => {
3037630388

3037730389
const localPath = path.join(TMP_DIR, repo.fullName)
30378-
const gitUrl = `https://${ GITHUB_TOKEN }@github.com/${ repo.fullName }.git`
30390+
const gitUrl = `https://${ GITHUB_TOKEN }@${ repo.fullName }.git`
3037930391

3038030392
const clone = () => {
3038130393
core.info(`Cloning ${ repo.fullName } into ${ localPath }`)
@@ -30578,7 +30590,7 @@ const run = async () => {
3057830590
core.info(`Repository Info`)
3057930591
core.info(`Slug : ${ item.repo.name }`)
3058030592
core.info(`Owner : ${ item.repo.user }`)
30581-
core.info(`Https Url : https://github.com/${ item.repo.fullName }`)
30593+
core.info(`Https Url : https://${ item.repo.fullName }`)
3058230594
core.info(`Branch : ${ item.repo.branch }`)
3058330595
core.info(' ')
3058430596
try {

src/config.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,24 @@ core.debug(
9797
)
9898

9999
const parseRepoName = (fullRepo) => {
100+
let host = 'github.com'
101+
102+
if (fullRepo.startsWith('http')) {
103+
const url = new URL(fullRepo)
104+
host = url.host
105+
106+
fullRepo = url.pathname.replace(/^\/+/, '') // Remove leading slash
107+
108+
core.info('Using custom host')
109+
}
110+
100111
const user = fullRepo.split('/')[0]
101112
const name = fullRepo.split('/')[1].split('@')[0]
102113
const branch = fullRepo.split('/')[1].split('@')[1] || 'default'
103114

104115
return {
105-
fullName: `${ user }/${ name }`,
116+
fullName: `${ host }/${ user }/${ name }`,
117+
host,
106118
user,
107119
name,
108120
branch

src/git.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const {
1515
const init = (repo) => {
1616

1717
const localPath = path.join(TMP_DIR, repo.fullName)
18-
const gitUrl = `https://${ GITHUB_TOKEN }@github.com/${ repo.fullName }.git`
18+
const gitUrl = `https://${ GITHUB_TOKEN }@${ repo.fullName }.git`
1919

2020
const clone = () => {
2121
core.info(`Cloning ${ repo.fullName } into ${ localPath }`)

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const run = async () => {
2828
core.info(`Repository Info`)
2929
core.info(`Slug : ${ item.repo.name }`)
3030
core.info(`Owner : ${ item.repo.user }`)
31-
core.info(`Https Url : https://github.com/${ item.repo.fullName }`)
31+
core.info(`Https Url : https://${ item.repo.fullName }`)
3232
core.info(`Branch : ${ item.repo.branch }`)
3333
core.info(' ')
3434
try {

0 commit comments

Comments
 (0)