Add if-no-files-found option to merge action

This commit is contained in:
Charlie Croom 2024-02-13 12:16:53 -05:00
parent 4c0ff1c489
commit 03a6dff9d4
No known key found for this signature in database
14 changed files with 202 additions and 44 deletions

52
dist/merge/index.js vendored
View file

@ -129407,6 +129407,7 @@ var Inputs;
(function (Inputs) {
Inputs["Name"] = "name";
Inputs["Pattern"] = "pattern";
Inputs["IfNoFilesFound"] = "if-no-files-found";
Inputs["SeparateDirectories"] = "separate-directories";
Inputs["RetentionDays"] = "retention-days";
Inputs["CompressionLevel"] = "compression-level";
@ -129486,6 +129487,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getInputs = void 0;
const core = __importStar(__nccwpck_require__(42186));
const constants_1 = __nccwpck_require__(80746);
const constants_2 = __nccwpck_require__(64068);
/**
* Helper to get all the inputs for the action
*/
@ -129494,9 +129496,15 @@ function getInputs() {
const pattern = core.getInput(constants_1.Inputs.Pattern, { required: true });
const separateDirectories = core.getBooleanInput(constants_1.Inputs.SeparateDirectories);
const deleteMerged = core.getBooleanInput(constants_1.Inputs.DeleteMerged);
const ifNoFilesFound = core.getInput(constants_1.Inputs.IfNoFilesFound);
const noFileBehavior = constants_2.NoFileOptions[ifNoFilesFound];
if (!noFileBehavior) {
core.setFailed(`Unrecognized ${constants_1.Inputs.IfNoFilesFound} input. Provided: ${ifNoFilesFound}. Available options: ${Object.keys(constants_2.NoFileOptions)}`);
}
const inputs = {
name,
pattern,
ifNoFilesFound: noFileBehavior,
separateDirectories,
deleteMerged,
retentionDays: 0,
@ -129574,6 +129582,7 @@ const core = __importStar(__nccwpck_require__(42186));
const minimatch_1 = __nccwpck_require__(61953);
const artifact_1 = __importDefault(__nccwpck_require__(79450));
const input_helper_1 = __nccwpck_require__(17661);
const constants_1 = __nccwpck_require__(64068);
const upload_artifact_1 = __nccwpck_require__(56680);
const search_1 = __nccwpck_require__(8725);
const PARALLEL_DOWNLOADS = 5;
@ -129594,7 +129603,22 @@ function run() {
const artifacts = listArtifactResponse.artifacts.filter(artifact => matcher.match(artifact.name));
core.debug(`Filtered from ${listArtifactResponse.artifacts.length} to ${artifacts.length} artifacts`);
if (artifacts.length === 0) {
throw new Error(`No artifacts found matching pattern '${inputs.pattern}'`);
// No files were found, different use cases warrant different types of behavior if nothing is found
switch (inputs.ifNoFilesFound) {
case constants_1.NoFileOptions.warn: {
core.warning(`No artifacts were found with the provided pattern: ${inputs.pattern}.`);
break;
}
case constants_1.NoFileOptions.error: {
core.setFailed(`No artifacts were found with the provided pattern: ${inputs.pattern}.`);
break;
}
case constants_1.NoFileOptions.ignore: {
core.info(`No artifacts were found with the provided pattern: ${inputs.pattern}.`);
break;
}
}
return;
}
core.info(`Preparing to download the following artifacts:`);
artifacts.forEach(artifact => {
@ -129635,6 +129659,32 @@ function run() {
exports.run = run;
/***/ }),
/***/ 64068:
/***/ ((__unused_webpack_module, exports) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.NoFileOptions = void 0;
var NoFileOptions;
(function (NoFileOptions) {
/**
* Default. Output a warning but do not fail the action
*/
NoFileOptions["warn"] = "warn";
/**
* Fail the action with an error message
*/
NoFileOptions["error"] = "error";
/**
* Do not output any warnings or errors, the action does not fail
*/
NoFileOptions["ignore"] = "ignore";
})(NoFileOptions = exports.NoFileOptions || (exports.NoFileOptions = {}));
/***/ }),
/***/ 8725: