From 4c7e849bb4971bedd744e558b136d249e8d8bd61 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 23:03:28 +0000 Subject: [PATCH 1/2] build(deps): bump @actions/artifact from 2.1.7 to 2.1.8 Bumps [@actions/artifact](https://github.com/actions/toolkit/tree/HEAD/packages/artifact) from 2.1.7 to 2.1.8. - [Changelog](https://github.com/actions/toolkit/blob/main/packages/artifact/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/artifact) --- updated-dependencies: - dependency-name: "@actions/artifact" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index a2929211..bea2ee0a 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/yarn.lock b/yarn.lock index f87351ce..9992630b 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 From 99e6b01d3914debada16000166178eaa25f56d2c Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Mon, 15 Jul 2024 13:14:08 +0200 Subject: [PATCH 2/2] github: use isGhes func from actions/artifact module Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- __tests__/github.test.ts | 22 ---------------------- src/github.ts | 9 ++++----- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/__tests__/github.test.ts b/__tests__/github.test.ts index f3418446..54c211a6 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 15deed42..c47eac73 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 {