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/package.json b/package.json index a292921..bea2ee0 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "registry": "https://registry.npmjs.org/" }, "dependencies": { - "@actions/artifact": "^2.1.7", + "@actions/artifact": "^2.1.8", "@actions/cache": "^3.2.4", "@actions/core": "^1.10.1", "@actions/exec": "^1.1.1", 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 { diff --git a/yarn.lock b/yarn.lock index f87351c..9992630 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12,9 +12,9 @@ __metadata: languageName: node linkType: hard -"@actions/artifact@npm:^2.1.7": - version: 2.1.7 - resolution: "@actions/artifact@npm:2.1.7" +"@actions/artifact@npm:^2.1.8": + version: 2.1.8 + resolution: "@actions/artifact@npm:2.1.8" dependencies: "@actions/core": ^1.10.0 "@actions/github": ^5.1.1 @@ -30,7 +30,7 @@ __metadata: jwt-decode: ^3.1.2 twirp-ts: ^2.5.0 unzip-stream: ^0.3.1 - checksum: 346c7caf43bdeb4a96c044ca3a6a005d82b977178b1a6be2c6954dfd59fef3344d2576bdd07c6cac9b54207cc88d7b1161cabd08c7cc15a1db86bf82463b36c7 + checksum: 51a47c21bcdac705abb61dbaef923f2760354c39bcad44a31b129e18bf31f646e5148f92ee7e1198275d1dba7bebfd1d1500ad7f62f6de1e65b57b2d092d5341 languageName: node linkType: hard @@ -1099,7 +1099,7 @@ __metadata: version: 0.0.0-use.local resolution: "@docker/actions-toolkit@workspace:." dependencies: - "@actions/artifact": ^2.1.7 + "@actions/artifact": ^2.1.8 "@actions/cache": ^3.2.4 "@actions/core": ^1.10.1 "@actions/exec": ^1.1.1