diff --git a/action.yml b/action.yml index 84d314d..e7cb071 100644 --- a/action.yml +++ b/action.yml @@ -89,6 +89,10 @@ inputs: secretEncodingType: description: 'The encoding type of the secret to decode. If not specified, the secret will not be decoded. Supported values: base64, hex, utf8' required: false + ignoreNotFound: + description: 'Whether or not the action should exit successfully if some requested secrets were not found.' + default: 'false' + required: false runs: using: 'node16' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index e92bf3c..9ffdbd1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3702,6 +3702,7 @@ function asPromise(normalizedOptions) { request._beforeError(new types_1.HTTPError(response)); return; } + request.destroy(); resolve(request.options.resolveBodyOnly ? response.body : response); }); const onError = (error) => { @@ -18935,6 +18936,7 @@ module.exports = { /***/ 8452: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +const core = __nccwpck_require__(2186); const jsonata = __nccwpck_require__(4245); const { WILDCARD } = __nccwpck_require__(4438); const { normalizeOutputKey } = __nccwpck_require__(1608); @@ -18959,6 +18961,7 @@ const { normalizeOutputKey } = __nccwpck_require__(1608); * @return {Promise[]>} */ async function getSecrets(secretRequests, client) { + const ignoreNotFound = (core.getInput('ignoreNotFound', { required: false }) || 'false').toLowerCase() != 'false'; const responseCache = new Map(); let results = []; @@ -18979,7 +18982,13 @@ async function getSecrets(secretRequests, client) { } catch (error) { const {response} = error; if (response?.statusCode === 404) { - throw Error(`Unable to retrieve result for "${path}" because it was not found: ${response.body.trim()}`) + msg = `Unable to retrieve result for "${path}" because it was not found: ${response.body.trim()}\n`; + if (ignoreNotFound) { + process.stdout.write(msg); + continue; + } else { + throw Error(msg); + } } throw error } diff --git a/src/secrets.js b/src/secrets.js index fe6a5e4..a6172bd 100644 --- a/src/secrets.js +++ b/src/secrets.js @@ -1,3 +1,4 @@ +const core = require('@actions/core'); const jsonata = require("jsonata"); const { WILDCARD } = require("./constants"); const { normalizeOutputKey } = require("./utils"); @@ -22,6 +23,7 @@ const { normalizeOutputKey } = require("./utils"); * @return {Promise[]>} */ async function getSecrets(secretRequests, client) { + const ignoreNotFound = (core.getInput('ignoreNotFound', { required: false }) || 'false').toLowerCase() != 'false'; const responseCache = new Map(); let results = []; @@ -42,7 +44,13 @@ async function getSecrets(secretRequests, client) { } catch (error) { const {response} = error; if (response?.statusCode === 404) { - throw Error(`Unable to retrieve result for "${path}" because it was not found: ${response.body.trim()}`) + msg = `Unable to retrieve result for "${path}" because it was not found: ${response.body.trim()}\n`; + if (ignoreNotFound) { + process.stdout.write(msg); + continue; + } else { + throw Error(msg); + } } throw error }