mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 03:16:09 +08:00
github: use isGhes func from actions/artifact module
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
4c7e849bb4
commit
99e6b01d39
@ -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');
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user