mirror of
https://gitea.com/actions/download-artifact.git
synced 2026-02-02 12:24:30 +07:00
Add a setting to specify what to do on hash mismatch and default it to error
This commit is contained in:
41
dist/index.js
vendored
41
dist/index.js
vendored
@@ -129353,7 +129353,15 @@ var Inputs;
|
||||
Inputs["MergeMultiple"] = "merge-multiple";
|
||||
Inputs["ArtifactIds"] = "artifact-ids";
|
||||
Inputs["SkipDecompress"] = "skip-decompress";
|
||||
Inputs["DigestMismatch"] = "digest-mismatch";
|
||||
})(Inputs || (Inputs = {}));
|
||||
var DigestMismatchBehavior;
|
||||
(function (DigestMismatchBehavior) {
|
||||
DigestMismatchBehavior["Ignore"] = "ignore";
|
||||
DigestMismatchBehavior["Info"] = "info";
|
||||
DigestMismatchBehavior["Warn"] = "warn";
|
||||
DigestMismatchBehavior["Error"] = "error";
|
||||
})(DigestMismatchBehavior || (DigestMismatchBehavior = {}));
|
||||
var Outputs;
|
||||
(function (Outputs) {
|
||||
Outputs["DownloadPath"] = "download-path";
|
||||
@@ -129386,8 +129394,15 @@ async function run() {
|
||||
artifactIds: getInput(Inputs.ArtifactIds, { required: false }),
|
||||
skipDecompress: getBooleanInput(Inputs.SkipDecompress, {
|
||||
required: false
|
||||
})
|
||||
}),
|
||||
digestMismatch: (getInput(Inputs.DigestMismatch, { required: false }) ||
|
||||
DigestMismatchBehavior.Error)
|
||||
};
|
||||
// Validate digest-mismatch input
|
||||
const validBehaviors = Object.values(DigestMismatchBehavior);
|
||||
if (!validBehaviors.includes(inputs.digestMismatch)) {
|
||||
throw new Error(`Invalid value for 'digest-mismatch': '${inputs.digestMismatch}'. Valid options are: ${validBehaviors.join(', ')}`);
|
||||
}
|
||||
if (!inputs.path) {
|
||||
inputs.path = process.env['GITHUB_WORKSPACE'] || process.cwd();
|
||||
}
|
||||
@@ -129500,6 +129515,7 @@ async function run() {
|
||||
})
|
||||
}));
|
||||
const chunkedPromises = chunk(downloadPromises, PARALLEL_DOWNLOADS);
|
||||
const digestMismatches = [];
|
||||
for (const chunk of chunkedPromises) {
|
||||
const chunkPromises = chunk.map(item => item.promise);
|
||||
const results = await Promise.all(chunkPromises);
|
||||
@@ -129507,10 +129523,31 @@ async function run() {
|
||||
const outcome = results[i];
|
||||
const artifactName = chunk[i].name;
|
||||
if (outcome.digestMismatch) {
|
||||
warning(`Artifact '${artifactName}' digest validation failed. Please verify the integrity of the artifact.`);
|
||||
digestMismatches.push(artifactName);
|
||||
const message = `Artifact '${artifactName}' digest validation failed. Please verify the integrity of the artifact.`;
|
||||
switch (inputs.digestMismatch) {
|
||||
case DigestMismatchBehavior.Ignore:
|
||||
// Do nothing
|
||||
break;
|
||||
case DigestMismatchBehavior.Info:
|
||||
info(message);
|
||||
break;
|
||||
case DigestMismatchBehavior.Warn:
|
||||
warning(message);
|
||||
break;
|
||||
case DigestMismatchBehavior.Error:
|
||||
// Collect all errors and fail at the end
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// If there were digest mismatches and behavior is 'error', fail the action
|
||||
if (digestMismatches.length > 0 &&
|
||||
inputs.digestMismatch === DigestMismatchBehavior.Error) {
|
||||
throw new Error(`Digest validation failed for artifact(s): ${digestMismatches.join(', ')}. ` +
|
||||
`Use 'digest-mismatch: warn' to continue on mismatch.`);
|
||||
}
|
||||
info(`Total of ${artifacts.length} artifact(s) downloaded`);
|
||||
setOutput(Outputs.DownloadPath, resolvedPath);
|
||||
info('Download artifact has finished successfully');
|
||||
|
||||
Reference in New Issue
Block a user