Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion packages/artifact/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ beforeEach(() => {
})

describe('isGhes', () => {
beforeEach(() => {
delete process.env.GITHUB_SERVER_URL
delete process.env.ACTIONS_RESULTS_URL
})

it('should return false when the request domain is github.com', () => {
process.env.GITHUB_SERVER_URL = 'https://github.com'
expect(config.isGhes()).toBe(false)
Expand All @@ -35,10 +40,22 @@ describe('isGhes', () => {
expect(config.isGhes()).toBe(false)
})

it('should return false when the request domain is specific to an enterprise', () => {
it('should return true on a self-hosted enterprise hostname when ACTIONS_RESULTS_URL is unset', () => {
process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com'
expect(config.isGhes()).toBe(true)
})

it('should return false on a self-hosted enterprise hostname when ACTIONS_RESULTS_URL is set (v2 backend available)', () => {
process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com'
process.env.ACTIONS_RESULTS_URL = 'https://results.example.com/'
expect(config.isGhes()).toBe(false)
})

it('should ignore ACTIONS_RESULTS_URL on github.com (already returns false there)', () => {
process.env.GITHUB_SERVER_URL = 'https://github.com'
process.env.ACTIONS_RESULTS_URL = 'https://results.example.com/'
expect(config.isGhes()).toBe(false)
})
})

describe('uploadChunkTimeoutEnv', () => {
Expand Down
16 changes: 15 additions & 1 deletion packages/artifact/src/internal/shared/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,21 @@ export function isGhes(): boolean {
const isGheHost = hostname.endsWith('.GHE.COM')
const isLocalHost = hostname.endsWith('.LOCALHOST')

return !isGitHubHost && !isGheHost && !isLocalHost
const hostnameLooksLikeGhes =
!isGitHubHost && !isGheHost && !isLocalHost

// GHES 3.13+ ships the artifact-storage-v2 backend that the v4+
// artifact client requires. The runner exposes the backend's
// presence via ACTIONS_RESULTS_URL (which getResultsServiceUrl()
// already requires for upload/download/list to function). When
// that env var is set we know the backend is reachable, so an
// unrecognised hostname does not need to short-circuit into a
// GHESNotSupportedError.
if (hostnameLooksLikeGhes && process.env['ACTIONS_RESULTS_URL']) {
return false
}

return hostnameLooksLikeGhes
}

export function getGitHubWorkspaceDir(): string {
Expand Down