From 386d77d22d6a25af02bad295e7842553e2baa599 Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Mon, 2 Feb 2026 17:13:16 +0100 Subject: [PATCH] github: vendor isGhes() func from @actions/artifact module Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- src/github.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/github.ts b/src/github.ts index 403f2543..cea092eb 100644 --- a/src/github.ts +++ b/src/github.ts @@ -22,7 +22,6 @@ 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'; @@ -96,10 +95,16 @@ export class GitHub { return process.env.GITHUB_API_URL || 'https://api.github.com'; } + // Can't use the isGhes() func from @actions/artifact due to @actions/artifact/lib/internal/shared/config + // being internal since ESM-only packages do not support internal exports. + // https://github.com/actions/toolkit/blob/8351a5d84d862813d1bb8bdeef87b215f8a946f9/packages/artifact/src/internal/shared/config.ts#L27 static get isGHES(): boolean { - // FIXME: we are using the function from GitHub artifact module but should - // be within core module when available. - return isGhes(); + const ghURL = new URL(GitHub.serverURL); + const hostname = ghURL.hostname.trimEnd().toUpperCase(); + const isGitHubHost = hostname === 'GITHUB.COM'; + const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); + const isLocalHost = hostname.endsWith('.LOCALHOST'); + return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } static get repository(): string {