Merge pull request #974 from crazy-max/vendor-isghes
github: vendor isGhes() func from @actions/artifact module
This commit is contained in:
@@ -22,7 +22,6 @@ import os from 'os';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {CreateArtifactRequest, FinalizeArtifactRequest, StringValue} from '@actions/artifact/lib/generated';
|
import {CreateArtifactRequest, FinalizeArtifactRequest, StringValue} from '@actions/artifact/lib/generated';
|
||||||
import {internalArtifactTwirpClient} from '@actions/artifact/lib/internal/shared/artifact-twirp-client';
|
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 {getBackendIdsFromToken} from '@actions/artifact/lib/internal/shared/util';
|
||||||
import {getExpiration} from '@actions/artifact/lib/internal/upload/retention';
|
import {getExpiration} from '@actions/artifact/lib/internal/upload/retention';
|
||||||
import {InvalidResponseError, NetworkError} from '@actions/artifact';
|
import {InvalidResponseError, NetworkError} from '@actions/artifact';
|
||||||
@@ -96,10 +95,16 @@ export class GitHub {
|
|||||||
return process.env.GITHUB_API_URL || 'https://api.github.com';
|
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 {
|
static get isGHES(): boolean {
|
||||||
// FIXME: we are using the function from GitHub artifact module but should
|
const ghURL = new URL(GitHub.serverURL);
|
||||||
// be within core module when available.
|
const hostname = ghURL.hostname.trimEnd().toUpperCase();
|
||||||
return isGhes();
|
const isGitHubHost = hostname === 'GITHUB.COM';
|
||||||
|
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
|
||||||
|
const isLocalHost = hostname.endsWith('.LOCALHOST');
|
||||||
|
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get repository(): string {
|
static get repository(): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user