From b680ef8e687a0a5d5d6a05a0373eb5c48e13f2ac Mon Sep 17 00:00:00 2001 From: eggyhead <28715808+eggyhead@users.noreply.github.com> Date: Wed, 31 Jan 2024 01:57:50 +0000 Subject: [PATCH] using results URL to check ghes for artifact --- packages/artifact/__tests__/config.test.ts | 8 ++------ packages/artifact/src/internal/shared/config.ts | 15 +++++---------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/packages/artifact/__tests__/config.test.ts b/packages/artifact/__tests__/config.test.ts index 418d087c..3822db18 100644 --- a/packages/artifact/__tests__/config.test.ts +++ b/packages/artifact/__tests__/config.test.ts @@ -12,15 +12,11 @@ describe('isGhes', () => { expect(config.isGhes()).toBe(false) }) - it('should return false when the request domain ends with ghe.com', () => { - process.env.GITHUB_SERVER_URL = 'https://github.ghe.com' + it('should return false when the request has ACTIONS_RESULTS_URL set', () => { + process.env.ACTIONS_RESULTS_URL = 'my.results.url' 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', () => { process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com' diff --git a/packages/artifact/src/internal/shared/config.ts b/packages/artifact/src/internal/shared/config.ts index 28aabf9d..8ab4dc20 100644 --- a/packages/artifact/src/internal/shared/config.ts +++ b/packages/artifact/src/internal/shared/config.ts @@ -27,16 +27,11 @@ export function isGhes(): boolean { const ghUrl = new URL( process.env['GITHUB_SERVER_URL'] || 'https://github.com' ) - - let githubHosts = [ - 'GITHUB.COM', - 'GITHUB.GHE.COM', - 'GITHUB.GHE.LOCALHOST' -]; - - const hostname = ghUrl.hostname.trimEnd().toUpperCase() - - return !githubHosts.includes(hostname) + + const isGitHubHost = (ghUrl.hostname.trimEnd().toUpperCase() === 'GITHUB.COM') + const isResultsServiceRequest = process.env['ACTIONS_RESULTS_URL'] != undefined + + return !isGitHubHost && !isResultsServiceRequest } export function getGitHubWorkspaceDir(): string {