mirror of
https://code.forgejo.org/actions/upload-artifact.git
synced 2025-05-19 07:34:45 +00:00
Merge bacb5b323b
into 184d73b71b
This commit is contained in:
commit
2deab709a8
4 changed files with 139 additions and 83 deletions
49
dist/merge/index.js
vendored
49
dist/merge/index.js
vendored
|
@ -127602,23 +127602,48 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.uploadArtifact = void 0;
|
||||
const core = __importStar(__nccwpck_require__(42186));
|
||||
const github = __importStar(__nccwpck_require__(95438));
|
||||
const artifact_1 = __importDefault(__nccwpck_require__(79450));
|
||||
function uploadArtifact(artifactName, filesToUpload, rootDirectory, options) {
|
||||
const artifact_1 = __importStar(__nccwpck_require__(79450));
|
||||
function deleteArtifactIfExists(artifactName) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const uploadResponse = yield artifact_1.default.uploadArtifact(artifactName, filesToUpload, rootDirectory, options);
|
||||
core.info(`Artifact ${artifactName} has been successfully uploaded! Final size is ${uploadResponse.size} bytes. Artifact ID is ${uploadResponse.id}`);
|
||||
core.setOutput('artifact-id', uploadResponse.id);
|
||||
const repository = github.context.repo;
|
||||
const artifactURL = `${github.context.serverUrl}/${repository.owner}/${repository.repo}/actions/runs/${github.context.runId}/artifacts/${uploadResponse.id}`;
|
||||
core.info(`Artifact download URL: ${artifactURL}`);
|
||||
core.setOutput('artifact-url', artifactURL);
|
||||
try {
|
||||
yield artifact_1.default.deleteArtifact(artifactName);
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof artifact_1.ArtifactNotFoundError) {
|
||||
core.debug(`Skipping deletion of '${artifactName}', it does not exist`);
|
||||
return;
|
||||
}
|
||||
// Best effort, we don't want to fail the action if this fails
|
||||
core.debug(`Unable to delete artifact: ${error.message}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
function uploadArtifact(artifactName, filesToUpload, rootDirectory, options, overwrite = false, retryAttempts = 3) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
if (overwrite) {
|
||||
yield deleteArtifactIfExists(artifactName);
|
||||
}
|
||||
const uploadResponse = yield artifact_1.default.uploadArtifact(artifactName, filesToUpload, rootDirectory, options);
|
||||
core.info(`Artifact ${artifactName} has been successfully uploaded! Final size is ${uploadResponse.size} bytes. Artifact ID is ${uploadResponse.id}`);
|
||||
core.setOutput('artifact-id', uploadResponse.id);
|
||||
const repository = github.context.repo;
|
||||
const artifactURL = `${github.context.serverUrl}/${repository.owner}/${repository.repo}/actions/runs/${github.context.runId}/artifacts/${uploadResponse.id}`;
|
||||
core.info(`Artifact download URL: ${artifactURL}`);
|
||||
core.setOutput('artifact-url', artifactURL);
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof artifact_1.InvalidResponseError &&
|
||||
error.message.includes('Conflict: an artifact with this name already exists on the workflow run') &&
|
||||
overwrite &&
|
||||
retryAttempts) {
|
||||
uploadArtifact(artifactName, filesToUpload, rootDirectory, options, overwrite, retryAttempts - 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.uploadArtifact = uploadArtifact;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue