Skip to content

Commit e8459a6

Browse files
leorossisimoneb
andauthored
Change type of exclude property to csv (#76)
* Change type of exclude parameter to csv * Update src/util.js Co-authored-by: Simone Busoli <simone.busoli@gmail.com>
1 parent 9ee764d commit e8459a6

File tree

3 files changed

+49
-11
lines changed

3 files changed

+49
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This action automatically approves and merges dependabot PRs.
1515

1616
### `exclude`
1717

18-
_Optional_ An array of packages that you don't want to auto-merge and would like to manually review to decide whether to upgrade or not.
18+
_Optional_ An comma separated value of packages that you don't want to auto-merge and would like to manually review to decide whether to upgrade or not.
1919

2020
### `approve-only`
2121

@@ -75,7 +75,7 @@ steps:
7575
- uses: fastify/github-action-merge-dependabot@v2.1.1
7676
with:
7777
github-token: ${{ secrets.GITHUB_TOKEN }}
78-
exclude: ['react']
78+
exclude: 'react,fastify'
7979
```
8080
8181
### Approving without merging

dist/index.js

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
134134
});
135135
};
136136
Object.defineProperty(exports, "__esModule", ({ value: true }));
137-
exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
137+
exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
138138
const command_1 = __nccwpck_require__(7351);
139139
const file_command_1 = __nccwpck_require__(717);
140140
const utils_1 = __nccwpck_require__(5278);
@@ -312,19 +312,30 @@ exports.debug = debug;
312312
/**
313313
* Adds an error issue
314314
* @param message error issue message. Errors will be converted to string via toString()
315+
* @param properties optional properties to add to the annotation.
315316
*/
316-
function error(message) {
317-
command_1.issue('error', message instanceof Error ? message.toString() : message);
317+
function error(message, properties = {}) {
318+
command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
318319
}
319320
exports.error = error;
320321
/**
321-
* Adds an warning issue
322+
* Adds a warning issue
322323
* @param message warning issue message. Errors will be converted to string via toString()
324+
* @param properties optional properties to add to the annotation.
323325
*/
324-
function warning(message) {
325-
command_1.issue('warning', message instanceof Error ? message.toString() : message);
326+
function warning(message, properties = {}) {
327+
command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
326328
}
327329
exports.warning = warning;
330+
/**
331+
* Adds a notice issue
332+
* @param message notice issue message. Errors will be converted to string via toString()
333+
* @param properties optional properties to add to the annotation.
334+
*/
335+
function notice(message, properties = {}) {
336+
command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
337+
}
338+
exports.notice = notice;
328339
/**
329340
* Writes info to log with console.log.
330341
* @param message info message
@@ -458,7 +469,7 @@ exports.issueCommand = issueCommand;
458469
// We use any as a valid input type
459470
/* eslint-disable @typescript-eslint/no-explicit-any */
460471
Object.defineProperty(exports, "__esModule", ({ value: true }));
461-
exports.toCommandValue = void 0;
472+
exports.toCommandProperties = exports.toCommandValue = void 0;
462473
/**
463474
* Sanitizes an input into a string so it can be passed into issueCommand safely
464475
* @param input input to sanitize into a string
@@ -473,6 +484,25 @@ function toCommandValue(input) {
473484
return JSON.stringify(input);
474485
}
475486
exports.toCommandValue = toCommandValue;
487+
/**
488+
*
489+
* @param annotationProperties
490+
* @returns The command properties to send with the actual annotation command
491+
* See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
492+
*/
493+
function toCommandProperties(annotationProperties) {
494+
if (!Object.keys(annotationProperties).length) {
495+
return {};
496+
}
497+
return {
498+
title: annotationProperties.title,
499+
line: annotationProperties.startLine,
500+
endLine: annotationProperties.endLine,
501+
col: annotationProperties.startColumn,
502+
endColumn: annotationProperties.endColumn
503+
};
504+
}
505+
exports.toCommandProperties = toCommandProperties;
476506
//# sourceMappingURL=utils.js.map
477507

478508
/***/ }),
@@ -6794,10 +6824,14 @@ const getMergeMethod = () => {
67946824
return mergeMethods[input]
67956825
}
67966826

6827+
const parseCommaSeparatedValue = (value) => {
6828+
return value.split(',').map(el => el.trim() );
6829+
}
6830+
67976831
exports.getInputs = () => ({
67986832
GITHUB_TOKEN: core.getInput('github-token', { required: true }),
67996833
MERGE_METHOD: getMergeMethod(),
6800-
EXCLUDE_PKGS: core.getInput('exclude') || [],
6834+
EXCLUDE_PKGS: parseCommaSeparatedValue(core.getInput('exclude')) || [],
68016835
MERGE_COMMENT: core.getInput('merge-comment') || '',
68026836
APPROVE_ONLY: /true/i.test(core.getInput('approve-only')),
68036837
API_URL: core.getInput('api-url'),

src/util.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ const getMergeMethod = () => {
2424
return mergeMethods[input]
2525
}
2626

27+
const parseCommaSeparatedValue = (value) => {
28+
return value.split(',').map(el => el.trim());
29+
}
30+
2731
exports.getInputs = () => ({
2832
GITHUB_TOKEN: core.getInput('github-token', { required: true }),
2933
MERGE_METHOD: getMergeMethod(),
30-
EXCLUDE_PKGS: core.getInput('exclude') || [],
34+
EXCLUDE_PKGS: parseCommaSeparatedValue(core.getInput('exclude')) || [],
3135
MERGE_COMMENT: core.getInput('merge-comment') || '',
3236
APPROVE_ONLY: /true/i.test(core.getInput('approve-only')),
3337
API_URL: core.getInput('api-url'),

0 commit comments

Comments
 (0)