diff --git a/__tests__/github.test.ts b/__tests__/github.test.ts index f341844..54c211a 100644 --- a/__tests__/github.test.ts +++ b/__tests__/github.test.ts @@ -85,28 +85,6 @@ describe('apiURL', () => { }); }); -describe('isGHES', () => { - afterEach(() => { - process.env.GITHUB_SERVER_URL = ''; - }); - it('should return false when the request domain is github.com', () => { - process.env.GITHUB_SERVER_URL = 'https://github.com'; - expect(GitHub.isGHES).toBe(false); - }); - it('should return false when the request domain ends with ghe.com', () => { - process.env.GITHUB_SERVER_URL = 'https://my.domain.ghe.com'; - expect(GitHub.isGHES).toBe(false); - }); - it('should return false when the request domain ends with ghe.localhost', () => { - process.env.GITHUB_SERVER_URL = 'https://my.domain.ghe.localhost'; - expect(GitHub.isGHES).toBe(false); - }); - it('should return true when the request domain is specific to an enterprise', () => { - process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com'; - expect(GitHub.isGHES).toBe(true); - }); -}); - describe('repository', () => { it('returns GitHub repository', async () => { expect(GitHub.repository).toEqual('docker/actions-toolkit'); diff --git a/src/github.ts b/src/github.ts index 15deed4..c47eac7 100644 --- a/src/github.ts +++ b/src/github.ts @@ -22,6 +22,7 @@ import os from 'os'; import path from 'path'; import {CreateArtifactRequest, FinalizeArtifactRequest, StringValue} from '@actions/artifact/lib/generated'; import {internalArtifactTwirpClient} from '@actions/artifact/lib/internal/shared/artifact-twirp-client'; +import {isGhes} from '@actions/artifact/lib/internal/shared/config'; import {getBackendIdsFromToken} from '@actions/artifact/lib/internal/shared/util'; import {getExpiration} from '@actions/artifact/lib/internal/upload/retention'; import {InvalidResponseError, NetworkError} from '@actions/artifact'; @@ -67,11 +68,9 @@ export class GitHub { } static get isGHES(): boolean { - const serverURL = new URL(GitHub.serverURL); - const hostname = serverURL.hostname.trimEnd().toUpperCase(); - const isGitHubHost = hostname === 'GITHUB.COM'; - const isGHESHost = hostname.endsWith('.GHE.COM') || hostname.endsWith('.GHE.LOCALHOST'); - return !isGitHubHost && !isGHESHost; + // FIXME: we are using the function from GitHub artifact module but should + // be within core module when available. + return isGhes(); } static get repository(): string {