mirror of
https://github.com/github/codeql-action.git
synced 2025-12-27 01:30:10 +08:00
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com> Co-authored-by: Henry Mercer <henrymercer@github.com>
144 lines
7.3 KiB
JavaScript
144 lines
7.3 KiB
JavaScript
"use strict";
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
var t = {};
|
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
t[p] = s[p];
|
|
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
t[p[i]] = s[p[i]];
|
|
}
|
|
return t;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.DefaultArtifactClient = void 0;
|
|
const core_1 = require("@actions/core");
|
|
const config_1 = require("./shared/config");
|
|
const upload_artifact_1 = require("./upload/upload-artifact");
|
|
const download_artifact_1 = require("./download/download-artifact");
|
|
const delete_artifact_1 = require("./delete/delete-artifact");
|
|
const get_artifact_1 = require("./find/get-artifact");
|
|
const list_artifacts_1 = require("./find/list-artifacts");
|
|
const errors_1 = require("./shared/errors");
|
|
/**
|
|
* The default artifact client that is used by the artifact action(s).
|
|
*/
|
|
class DefaultArtifactClient {
|
|
uploadArtifact(name, files, rootDirectory, options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
try {
|
|
if ((0, config_1.isGhes)()) {
|
|
throw new errors_1.GHESNotSupportedError();
|
|
}
|
|
return (0, upload_artifact_1.uploadArtifact)(name, files, rootDirectory, options);
|
|
}
|
|
catch (error) {
|
|
(0, core_1.warning)(`Artifact upload failed with error: ${error}.
|
|
|
|
Errors can be temporary, so please try again and optionally run the action with debug mode enabled for more information.
|
|
|
|
If the error persists, please check whether Actions is operating normally at [https://githubstatus.com](https://www.githubstatus.com).`);
|
|
throw error;
|
|
}
|
|
});
|
|
}
|
|
downloadArtifact(artifactId, options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
try {
|
|
if ((0, config_1.isGhes)()) {
|
|
throw new errors_1.GHESNotSupportedError();
|
|
}
|
|
if (options === null || options === void 0 ? void 0 : options.findBy) {
|
|
const { findBy: { repositoryOwner, repositoryName, token } } = options, downloadOptions = __rest(options, ["findBy"]);
|
|
return (0, download_artifact_1.downloadArtifactPublic)(artifactId, repositoryOwner, repositoryName, token, downloadOptions);
|
|
}
|
|
return (0, download_artifact_1.downloadArtifactInternal)(artifactId, options);
|
|
}
|
|
catch (error) {
|
|
(0, core_1.warning)(`Download Artifact failed with error: ${error}.
|
|
|
|
Errors can be temporary, so please try again and optionally run the action with debug mode enabled for more information.
|
|
|
|
If the error persists, please check whether Actions and API requests are operating normally at [https://githubstatus.com](https://www.githubstatus.com).`);
|
|
throw error;
|
|
}
|
|
});
|
|
}
|
|
listArtifacts(options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
try {
|
|
if ((0, config_1.isGhes)()) {
|
|
throw new errors_1.GHESNotSupportedError();
|
|
}
|
|
if (options === null || options === void 0 ? void 0 : options.findBy) {
|
|
const { findBy: { workflowRunId, repositoryOwner, repositoryName, token } } = options;
|
|
return (0, list_artifacts_1.listArtifactsPublic)(workflowRunId, repositoryOwner, repositoryName, token, options === null || options === void 0 ? void 0 : options.latest);
|
|
}
|
|
return (0, list_artifacts_1.listArtifactsInternal)(options === null || options === void 0 ? void 0 : options.latest);
|
|
}
|
|
catch (error) {
|
|
(0, core_1.warning)(`Listing Artifacts failed with error: ${error}.
|
|
|
|
Errors can be temporary, so please try again and optionally run the action with debug mode enabled for more information.
|
|
|
|
If the error persists, please check whether Actions and API requests are operating normally at [https://githubstatus.com](https://www.githubstatus.com).`);
|
|
throw error;
|
|
}
|
|
});
|
|
}
|
|
getArtifact(artifactName, options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
try {
|
|
if ((0, config_1.isGhes)()) {
|
|
throw new errors_1.GHESNotSupportedError();
|
|
}
|
|
if (options === null || options === void 0 ? void 0 : options.findBy) {
|
|
const { findBy: { workflowRunId, repositoryOwner, repositoryName, token } } = options;
|
|
return (0, get_artifact_1.getArtifactPublic)(artifactName, workflowRunId, repositoryOwner, repositoryName, token);
|
|
}
|
|
return (0, get_artifact_1.getArtifactInternal)(artifactName);
|
|
}
|
|
catch (error) {
|
|
(0, core_1.warning)(`Get Artifact failed with error: ${error}.
|
|
|
|
Errors can be temporary, so please try again and optionally run the action with debug mode enabled for more information.
|
|
|
|
If the error persists, please check whether Actions and API requests are operating normally at [https://githubstatus.com](https://www.githubstatus.com).`);
|
|
throw error;
|
|
}
|
|
});
|
|
}
|
|
deleteArtifact(artifactName, options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
try {
|
|
if ((0, config_1.isGhes)()) {
|
|
throw new errors_1.GHESNotSupportedError();
|
|
}
|
|
if (options === null || options === void 0 ? void 0 : options.findBy) {
|
|
const { findBy: { repositoryOwner, repositoryName, workflowRunId, token } } = options;
|
|
return (0, delete_artifact_1.deleteArtifactPublic)(artifactName, workflowRunId, repositoryOwner, repositoryName, token);
|
|
}
|
|
return (0, delete_artifact_1.deleteArtifactInternal)(artifactName);
|
|
}
|
|
catch (error) {
|
|
(0, core_1.warning)(`Delete Artifact failed with error: ${error}.
|
|
|
|
Errors can be temporary, so please try again and optionally run the action with debug mode enabled for more information.
|
|
|
|
If the error persists, please check whether Actions and API requests are operating normally at [https://githubstatus.com](https://www.githubstatus.com).`);
|
|
throw error;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
exports.DefaultArtifactClient = DefaultArtifactClient;
|
|
//# sourceMappingURL=client.js.map
|