mirror of https://github.com/actions/toolkit
using results URL to check ghes for artifact
parent
fe8c762d61
commit
b680ef8e68
|
@ -12,15 +12,11 @@ describe('isGhes', () => {
|
||||||
expect(config.isGhes()).toBe(false)
|
expect(config.isGhes()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return false when the request domain ends with ghe.com', () => {
|
it('should return false when the request has ACTIONS_RESULTS_URL set', () => {
|
||||||
process.env.GITHUB_SERVER_URL = 'https://github.ghe.com'
|
process.env.ACTIONS_RESULTS_URL = 'my.results.url'
|
||||||
expect(config.isGhes()).toBe(false)
|
expect(config.isGhes()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return false when the request domain ends with ghe.localhost', () => {
|
|
||||||
process.env.GITHUB_SERVER_URL = 'https://github.ghe.localhost'
|
|
||||||
expect(config.isGhes()).toBe(false)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should return false when the request domain is specific to an enterprise', () => {
|
it('should return false when the request domain is specific to an enterprise', () => {
|
||||||
process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com'
|
process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com'
|
||||||
|
|
|
@ -27,16 +27,11 @@ export function isGhes(): boolean {
|
||||||
const ghUrl = new URL(
|
const ghUrl = new URL(
|
||||||
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||||
)
|
)
|
||||||
|
|
||||||
let githubHosts = [
|
const isGitHubHost = (ghUrl.hostname.trimEnd().toUpperCase() === 'GITHUB.COM')
|
||||||
'GITHUB.COM',
|
const isResultsServiceRequest = process.env['ACTIONS_RESULTS_URL'] != undefined
|
||||||
'GITHUB.GHE.COM',
|
|
||||||
'GITHUB.GHE.LOCALHOST'
|
return !isGitHubHost && !isResultsServiceRequest
|
||||||
];
|
|
||||||
|
|
||||||
const hostname = ghUrl.hostname.trimEnd().toUpperCase()
|
|
||||||
|
|
||||||
return !githubHosts.includes(hostname)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getGitHubWorkspaceDir(): string {
|
export function getGitHubWorkspaceDir(): string {
|
||||||
|
|
Loading…
Reference in New Issue