mirror of
https://github.com/actions/download-artifact.git
synced 2024-12-27 01:32:15 -05:00
Add allow-not-found input in case artifact does not exist
This commit is contained in:
parent
d0ce8fd116
commit
3421aafe77
4 changed files with 56 additions and 28 deletions
|
@ -17,6 +17,10 @@ inputs:
|
|||
If false, the downloaded artifacts will be extracted into individual named directories within the specified path.'
|
||||
required: false
|
||||
default: 'false'
|
||||
allow-not-found:
|
||||
description: 'If an artifact was not found, do not cause the action to fail.'
|
||||
required: false
|
||||
default: 'false'
|
||||
github-token:
|
||||
description: 'The GitHub token used to authenticate with the GitHub API.
|
||||
This is required when downloading artifacts from a different repository or from a different workflow run.
|
||||
|
|
43
dist/index.js
vendored
43
dist/index.js
vendored
|
@ -50954,8 +50954,8 @@ utils.walkdir = function(dirpath, base, callback) {
|
|||
res.forEach(function(dirEntry) {
|
||||
results.push(dirEntry);
|
||||
});
|
||||
|
||||
next();
|
||||
|
||||
next();
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
|
@ -120473,6 +120473,7 @@ var Inputs;
|
|||
Inputs["RunID"] = "run-id";
|
||||
Inputs["Pattern"] = "pattern";
|
||||
Inputs["MergeMultiple"] = "merge-multiple";
|
||||
Inputs["AllowNotFound"] = "allow-not-found";
|
||||
})(Inputs || (exports.Inputs = Inputs = {}));
|
||||
var Outputs;
|
||||
(function (Outputs) {
|
||||
|
@ -120546,7 +120547,10 @@ function run() {
|
|||
repository: core.getInput(constants_1.Inputs.Repository, { required: false }),
|
||||
runID: parseInt(core.getInput(constants_1.Inputs.RunID, { required: false })),
|
||||
pattern: core.getInput(constants_1.Inputs.Pattern, { required: false }),
|
||||
mergeMultiple: core.getBooleanInput(constants_1.Inputs.MergeMultiple, { required: false })
|
||||
mergeMultiple: core.getBooleanInput(constants_1.Inputs.MergeMultiple, {
|
||||
required: false
|
||||
}),
|
||||
allowNotFound: core.getBooleanInput(constants_1.Inputs.AllowNotFound, { required: false })
|
||||
};
|
||||
if (!inputs.path) {
|
||||
inputs.path = process.env['GITHUB_WORKSPACE'] || process.cwd();
|
||||
|
@ -120555,7 +120559,7 @@ function run() {
|
|||
inputs.path = inputs.path.replace('~', os.homedir());
|
||||
}
|
||||
const isSingleArtifactDownload = !!inputs.name;
|
||||
const resolvedPath = path.resolve(inputs.path);
|
||||
let resolvedPath = path.resolve(inputs.path);
|
||||
core.debug(`Resolved path is ${resolvedPath}`);
|
||||
const options = {};
|
||||
if (inputs.token) {
|
||||
|
@ -120573,12 +120577,23 @@ function run() {
|
|||
let artifacts = [];
|
||||
if (isSingleArtifactDownload) {
|
||||
core.info(`Downloading single artifact`);
|
||||
const { artifact: targetArtifact } = yield artifact_1.default.getArtifact(inputs.name, options);
|
||||
const targetArtifact = yield artifact_1.default
|
||||
.getArtifact(inputs.name, options)
|
||||
.catch(() => null);
|
||||
if (!targetArtifact) {
|
||||
throw new Error(`Artifact '${inputs.name}' not found`);
|
||||
const message = `Artifact '${inputs.name}' not found`;
|
||||
if (!inputs.allowNotFound) {
|
||||
throw new Error(message);
|
||||
}
|
||||
else {
|
||||
core.warning(message);
|
||||
resolvedPath = '';
|
||||
}
|
||||
}
|
||||
else {
|
||||
core.debug(`Found named artifact '${inputs.name}' (ID: ${targetArtifact.artifact.id}, Size: ${targetArtifact.artifact.size})`);
|
||||
artifacts = [targetArtifact.artifact];
|
||||
}
|
||||
core.debug(`Found named artifact '${inputs.name}' (ID: ${targetArtifact.id}, Size: ${targetArtifact.size})`);
|
||||
artifacts = [targetArtifact];
|
||||
}
|
||||
else {
|
||||
const listArtifactResponse = yield artifact_1.default.listArtifacts(Object.assign({ latest: true }, options));
|
||||
|
@ -130008,11 +130023,11 @@ class LRUCache {
|
|||
b.__abortController instanceof AC);
|
||||
}
|
||||
async fetch(k, fetchOptions = {}) {
|
||||
const {
|
||||
const {
|
||||
// get options
|
||||
allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet,
|
||||
allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet,
|
||||
// set options
|
||||
ttl = this.ttl, noDisposeOnSet = this.noDisposeOnSet, size = 0, sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL,
|
||||
ttl = this.ttl, noDisposeOnSet = this.noDisposeOnSet, size = 0, sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL,
|
||||
// fetch exclusive options
|
||||
noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, ignoreFetchAbort = this.ignoreFetchAbort, allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, context, forceRefresh = false, status, signal, } = fetchOptions;
|
||||
if (!this.#hasFetchMethod) {
|
||||
|
@ -130637,10 +130652,10 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"]
|
|||
/******/ } finally {
|
||||
/******/ if(threw) delete __webpack_module_cache__[moduleId];
|
||||
/******/ }
|
||||
/******/
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.loaded = true;
|
||||
/******/
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
|
@ -130654,7 +130669,7 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"]
|
|||
/******/ return module;
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/
|
||||
/******/ /* webpack/runtime/compat */
|
||||
/******/
|
||||
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
|
||||
|
|
|
@ -5,7 +5,8 @@ export enum Inputs {
|
|||
Repository = 'repository',
|
||||
RunID = 'run-id',
|
||||
Pattern = 'pattern',
|
||||
MergeMultiple = 'merge-multiple'
|
||||
MergeMultiple = 'merge-multiple',
|
||||
AllowNotFound = 'allow-not-found'
|
||||
}
|
||||
|
||||
export enum Outputs {
|
||||
|
|
|
@ -23,7 +23,10 @@ async function run(): Promise<void> {
|
|||
repository: core.getInput(Inputs.Repository, {required: false}),
|
||||
runID: parseInt(core.getInput(Inputs.RunID, {required: false})),
|
||||
pattern: core.getInput(Inputs.Pattern, {required: false}),
|
||||
mergeMultiple: core.getBooleanInput(Inputs.MergeMultiple, {required: false})
|
||||
mergeMultiple: core.getBooleanInput(Inputs.MergeMultiple, {
|
||||
required: false
|
||||
}),
|
||||
allowNotFound: core.getBooleanInput(Inputs.AllowNotFound, {required: false})
|
||||
}
|
||||
|
||||
if (!inputs.path) {
|
||||
|
@ -35,7 +38,7 @@ async function run(): Promise<void> {
|
|||
}
|
||||
|
||||
const isSingleArtifactDownload = !!inputs.name
|
||||
const resolvedPath = path.resolve(inputs.path)
|
||||
let resolvedPath = path.resolve(inputs.path)
|
||||
core.debug(`Resolved path is ${resolvedPath}`)
|
||||
|
||||
const options: FindOptions = {}
|
||||
|
@ -60,20 +63,25 @@ async function run(): Promise<void> {
|
|||
if (isSingleArtifactDownload) {
|
||||
core.info(`Downloading single artifact`)
|
||||
|
||||
const {artifact: targetArtifact} = await artifactClient.getArtifact(
|
||||
inputs.name,
|
||||
options
|
||||
)
|
||||
const targetArtifact = await artifactClient
|
||||
.getArtifact(inputs.name, options)
|
||||
.catch(() => null)
|
||||
|
||||
if (!targetArtifact) {
|
||||
throw new Error(`Artifact '${inputs.name}' not found`)
|
||||
const message = `Artifact '${inputs.name}' not found`
|
||||
if (!inputs.allowNotFound) {
|
||||
throw new Error(message)
|
||||
} else {
|
||||
core.warning(message)
|
||||
resolvedPath = ''
|
||||
}
|
||||
} else {
|
||||
core.debug(
|
||||
`Found named artifact '${inputs.name}' (ID: ${targetArtifact.artifact.id}, Size: ${targetArtifact.artifact.size})`
|
||||
)
|
||||
|
||||
artifacts = [targetArtifact.artifact]
|
||||
}
|
||||
|
||||
core.debug(
|
||||
`Found named artifact '${inputs.name}' (ID: ${targetArtifact.id}, Size: ${targetArtifact.size})`
|
||||
)
|
||||
|
||||
artifacts = [targetArtifact]
|
||||
} else {
|
||||
const listArtifactResponse = await artifactClient.listArtifacts({
|
||||
latest: true,
|
||||
|
|
Loading…
Reference in a new issue