github(artifact): check upload artifact support for GHES

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2024-06-24 13:25:51 +02:00
parent 6f66565779
commit 4ce8a708c9
No known key found for this signature in database
GPG Key ID: ADE44D8C9D44FBE4

View File

@ -22,6 +22,7 @@ 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';
@ -122,6 +123,10 @@ export class GitHub {
} }
public static async uploadArtifact(opts: UploadArtifactOpts): Promise<UploadArtifactResponse> { public static async uploadArtifact(opts: UploadArtifactOpts): Promise<UploadArtifactResponse> {
if (isGhes()) {
throw new Error('@actions/artifact v2.0.0+ is currently not supported on GHES.');
}
const artifactName = path.basename(opts.filename); const artifactName = path.basename(opts.filename);
const backendIds = getBackendIdsFromToken(); const backendIds = getBackendIdsFromToken();
const artifactClient = internalArtifactTwirpClient(); const artifactClient = internalArtifactTwirpClient();