From 954bb9f9d7ed143baa839181a6bd4826f1e75d83 Mon Sep 17 00:00:00 2001 From: "optic-release-automation[bot]" <94357573+optic-release-automation[bot]@users.noreply.github.com> Date: Mon, 3 Oct 2022 15:54:54 +0100 Subject: [PATCH] Release v3.4.0 (#285) Co-authored-by: simoneb --- dist/index.js | 59 +++++++++++++++++++++++++++++------------------ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/dist/index.js b/dist/index.js index 9dd3c54d..40c6914c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -140,7 +140,6 @@ const file_command_1 = __nccwpck_require__(717); const utils_1 = __nccwpck_require__(278); const os = __importStar(__nccwpck_require__(37)); const path = __importStar(__nccwpck_require__(17)); -const uuid_1 = __nccwpck_require__(974); const oidc_utils_1 = __nccwpck_require__(41); /** * The code to exit an action @@ -170,20 +169,9 @@ function exportVariable(name, val) { process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - const delimiter = `ghadelimiter_${uuid_1.v4()}`; - // These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter. - if (name.includes(delimiter)) { - throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); - } - if (convertedVal.includes(delimiter)) { - throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); - } - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); + return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); } + command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; /** @@ -201,7 +189,7 @@ exports.setSecret = setSecret; function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueCommand('PATH', inputPath); + file_command_1.issueFileCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); @@ -241,7 +229,10 @@ function getMultilineInput(name, options) { const inputs = getInput(name, options) .split('\n') .filter(x => x !== ''); - return inputs; + if (options && options.trimWhitespace === false) { + return inputs; + } + return inputs.map(input => input.trim()); } exports.getMultilineInput = getMultilineInput; /** @@ -274,8 +265,12 @@ exports.getBooleanInput = getBooleanInput; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { + const filePath = process.env['GITHUB_OUTPUT'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); + } process.stdout.write(os.EOL); - command_1.issueCommand('set-output', { name }, value); + command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); } exports.setOutput = setOutput; /** @@ -404,7 +399,11 @@ exports.group = group; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); + const filePath = process.env['GITHUB_STATE'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); + } + command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); } exports.saveState = saveState; /** @@ -470,13 +469,14 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.issueCommand = void 0; +exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__nccwpck_require__(147)); const os = __importStar(__nccwpck_require__(37)); +const uuid_1 = __nccwpck_require__(974); const utils_1 = __nccwpck_require__(278); -function issueCommand(command, message) { +function issueFileCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); @@ -488,7 +488,22 @@ function issueCommand(command, message) { encoding: 'utf8' }); } -exports.issueCommand = issueCommand; +exports.issueFileCommand = issueFileCommand; +function prepareKeyValueMessage(key, value) { + const delimiter = `ghadelimiter_${uuid_1.v4()}`; + const convertedValue = utils_1.toCommandValue(value); + // These should realistically never happen, but just in case someone finds a + // way to exploit uuid generation let's not allow keys or values that contain + // the delimiter. + if (key.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } + if (convertedValue.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } + return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; +} +exports.prepareKeyValueMessage = prepareKeyValueMessage; //# sourceMappingURL=file-command.js.map /***/ }), @@ -3189,7 +3204,7 @@ module.exports = require("util"); /***/ ((module) => { "use strict"; -module.exports = JSON.parse('{"name":"github-action-merge-dependabot","version":"3.3.2","description":"A GitHub action to automatically merge and approve Dependabot pull requests","main":"src/index.js","scripts":{"build":"ncc build src/index.js","lint":"eslint .","test":"tap test/**.test.js","prepare":"husky install"},"author":{"name":"Salman Mitha","email":"SalmanMitha@gmail.com"},"contributors":["Simone Busoli "],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/fastify/github-action-merge-dependabot.git"},"bugs":{"url":"https://github.com/fastify/github-action-merge-dependabot/issues"},"homepage":"https://github.com/fastify/github-action-merge-dependabot#readme","dependencies":{"@actions/core":"^1.9.1","@actions/github":"^5.1.1","actions-toolkit":"github:nearform/actions-toolkit","gitdiff-parser":"^0.2.2","semver":"^7.3.7"},"devDependencies":{"@vercel/ncc":"^0.34.0","eslint":"^8.24.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.2.1","husky":"^8.0.1","prettier":"^2.7.1","proxyquire":"^2.1.3","sinon":"^14.0.0","tap":"^16.3.0"}}'); +module.exports = JSON.parse('{"name":"github-action-merge-dependabot","version":"3.4.0","description":"A GitHub action to automatically merge and approve Dependabot pull requests","main":"src/index.js","scripts":{"build":"ncc build src/index.js","lint":"eslint .","test":"tap test/**.test.js","prepare":"husky install"},"author":{"name":"Salman Mitha","email":"SalmanMitha@gmail.com"},"contributors":["Simone Busoli "],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/fastify/github-action-merge-dependabot.git"},"bugs":{"url":"https://github.com/fastify/github-action-merge-dependabot/issues"},"homepage":"https://github.com/fastify/github-action-merge-dependabot#readme","dependencies":{"@actions/core":"^1.9.1","@actions/github":"^5.1.1","actions-toolkit":"github:nearform/actions-toolkit","gitdiff-parser":"^0.2.2","semver":"^7.3.7"},"devDependencies":{"@vercel/ncc":"^0.34.0","eslint":"^8.24.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.2.1","husky":"^8.0.1","prettier":"^2.7.1","proxyquire":"^2.1.3","sinon":"^14.0.0","tap":"^16.3.0"}}'); /***/ }) diff --git a/package-lock.json b/package-lock.json index 8eb34cb4..fc292209 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "github-action-merge-dependabot", - "version": "3.3.2", + "version": "3.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "github-action-merge-dependabot", - "version": "3.3.2", + "version": "3.4.0", "license": "MIT", "dependencies": { "@actions/core": "^1.9.1", diff --git a/package.json b/package.json index f8f38644..1c668023 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "github-action-merge-dependabot", - "version": "3.3.2", + "version": "3.4.0", "description": "A GitHub action to automatically merge and approve Dependabot pull requests", "main": "src/index.js", "scripts": {