Skip to content

Commit 954bb9f

Browse files
Release v3.4.0 (#285)
Co-authored-by: simoneb <actions@users.noreply.github.com>
1 parent 46e2239 commit 954bb9f

File tree

3 files changed

+40
-25
lines changed

3 files changed

+40
-25
lines changed

dist/index.js

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ const file_command_1 = __nccwpck_require__(717);
140140
const utils_1 = __nccwpck_require__(278);
141141
const os = __importStar(__nccwpck_require__(37));
142142
const path = __importStar(__nccwpck_require__(17));
143-
const uuid_1 = __nccwpck_require__(974);
144143
const oidc_utils_1 = __nccwpck_require__(41);
145144
/**
146145
* The code to exit an action
@@ -170,20 +169,9 @@ function exportVariable(name, val) {
170169
process.env[name] = convertedVal;
171170
const filePath = process.env['GITHUB_ENV'] || '';
172171
if (filePath) {
173-
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
174-
// 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.
175-
if (name.includes(delimiter)) {
176-
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
177-
}
178-
if (convertedVal.includes(delimiter)) {
179-
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
180-
}
181-
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
182-
file_command_1.issueCommand('ENV', commandValue);
183-
}
184-
else {
185-
command_1.issueCommand('set-env', { name }, convertedVal);
172+
return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
186173
}
174+
command_1.issueCommand('set-env', { name }, convertedVal);
187175
}
188176
exports.exportVariable = exportVariable;
189177
/**
@@ -201,7 +189,7 @@ exports.setSecret = setSecret;
201189
function addPath(inputPath) {
202190
const filePath = process.env['GITHUB_PATH'] || '';
203191
if (filePath) {
204-
file_command_1.issueCommand('PATH', inputPath);
192+
file_command_1.issueFileCommand('PATH', inputPath);
205193
}
206194
else {
207195
command_1.issueCommand('add-path', {}, inputPath);
@@ -241,7 +229,10 @@ function getMultilineInput(name, options) {
241229
const inputs = getInput(name, options)
242230
.split('\n')
243231
.filter(x => x !== '');
244-
return inputs;
232+
if (options && options.trimWhitespace === false) {
233+
return inputs;
234+
}
235+
return inputs.map(input => input.trim());
245236
}
246237
exports.getMultilineInput = getMultilineInput;
247238
/**
@@ -274,8 +265,12 @@ exports.getBooleanInput = getBooleanInput;
274265
*/
275266
// eslint-disable-next-line @typescript-eslint/no-explicit-any
276267
function setOutput(name, value) {
268+
const filePath = process.env['GITHUB_OUTPUT'] || '';
269+
if (filePath) {
270+
return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
271+
}
277272
process.stdout.write(os.EOL);
278-
command_1.issueCommand('set-output', { name }, value);
273+
command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value));
279274
}
280275
exports.setOutput = setOutput;
281276
/**
@@ -404,7 +399,11 @@ exports.group = group;
404399
*/
405400
// eslint-disable-next-line @typescript-eslint/no-explicit-any
406401
function saveState(name, value) {
407-
command_1.issueCommand('save-state', { name }, value);
402+
const filePath = process.env['GITHUB_STATE'] || '';
403+
if (filePath) {
404+
return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
405+
}
406+
command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
408407
}
409408
exports.saveState = saveState;
410409
/**
@@ -470,13 +469,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
470469
return result;
471470
};
472471
Object.defineProperty(exports, "__esModule", ({ value: true }));
473-
exports.issueCommand = void 0;
472+
exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
474473
// We use any as a valid input type
475474
/* eslint-disable @typescript-eslint/no-explicit-any */
476475
const fs = __importStar(__nccwpck_require__(147));
477476
const os = __importStar(__nccwpck_require__(37));
477+
const uuid_1 = __nccwpck_require__(974);
478478
const utils_1 = __nccwpck_require__(278);
479-
function issueCommand(command, message) {
479+
function issueFileCommand(command, message) {
480480
const filePath = process.env[`GITHUB_${command}`];
481481
if (!filePath) {
482482
throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -488,7 +488,22 @@ function issueCommand(command, message) {
488488
encoding: 'utf8'
489489
});
490490
}
491-
exports.issueCommand = issueCommand;
491+
exports.issueFileCommand = issueFileCommand;
492+
function prepareKeyValueMessage(key, value) {
493+
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
494+
const convertedValue = utils_1.toCommandValue(value);
495+
// These should realistically never happen, but just in case someone finds a
496+
// way to exploit uuid generation let's not allow keys or values that contain
497+
// the delimiter.
498+
if (key.includes(delimiter)) {
499+
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
500+
}
501+
if (convertedValue.includes(delimiter)) {
502+
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
503+
}
504+
return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
505+
}
506+
exports.prepareKeyValueMessage = prepareKeyValueMessage;
492507
//# sourceMappingURL=file-command.js.map
493508

494509
/***/ }),
@@ -3189,7 +3204,7 @@ module.exports = require("util");
31893204
/***/ ((module) => {
31903205

31913206
"use strict";
3192-
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 <simone.busoli@nearform.com>"],"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"}}');
3207+
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 <simone.busoli@nearform.com>"],"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"}}');
31933208

31943209
/***/ })
31953210

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-action-merge-dependabot",
3-
"version": "3.3.2",
3+
"version": "3.4.0",
44
"description": "A GitHub action to automatically merge and approve Dependabot pull requests",
55
"main": "src/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)