Skip to content

Commit

Permalink
Change type of exclude property to csv (#76)
Browse files Browse the repository at this point in the history
* Change type of exclude parameter to csv

* Update src/util.js

Co-authored-by: Simone Busoli <simone.busoli@gmail.com>
  • Loading branch information
leorossi and simoneb authored Sep 20, 2021
1 parent 9ee764d commit e8459a6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This action automatically approves and merges dependabot PRs.

### `exclude`

_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.
_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.

### `approve-only`

Expand Down Expand Up @@ -75,7 +75,7 @@ steps:
- uses: fastify/github-action-merge-dependabot@v2.1.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
exclude: ['react']
exclude: 'react,fastify'
```
### Approving without merging
Expand Down
50 changes: 42 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
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;
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;
const command_1 = __nccwpck_require__(7351);
const file_command_1 = __nccwpck_require__(717);
const utils_1 = __nccwpck_require__(5278);
Expand Down Expand Up @@ -312,19 +312,30 @@ exports.debug = debug;
/**
* Adds an error issue
* @param message error issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/
function error(message) {
command_1.issue('error', message instanceof Error ? message.toString() : message);
function error(message, properties = {}) {
command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
exports.error = error;
/**
* Adds an warning issue
* Adds a warning issue
* @param message warning issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/
function warning(message) {
command_1.issue('warning', message instanceof Error ? message.toString() : message);
function warning(message, properties = {}) {
command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
exports.warning = warning;
/**
* Adds a notice issue
* @param message notice issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/
function notice(message, properties = {}) {
command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
exports.notice = notice;
/**
* Writes info to log with console.log.
* @param message info message
Expand Down Expand Up @@ -458,7 +469,7 @@ exports.issueCommand = issueCommand;
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.toCommandValue = void 0;
exports.toCommandProperties = exports.toCommandValue = void 0;
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
Expand All @@ -473,6 +484,25 @@ function toCommandValue(input) {
return JSON.stringify(input);
}
exports.toCommandValue = toCommandValue;
/**
*
* @param annotationProperties
* @returns The command properties to send with the actual annotation command
* See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
*/
function toCommandProperties(annotationProperties) {
if (!Object.keys(annotationProperties).length) {
return {};
}
return {
title: annotationProperties.title,
line: annotationProperties.startLine,
endLine: annotationProperties.endLine,
col: annotationProperties.startColumn,
endColumn: annotationProperties.endColumn
};
}
exports.toCommandProperties = toCommandProperties;
//# sourceMappingURL=utils.js.map

/***/ }),
Expand Down Expand Up @@ -6794,10 +6824,14 @@ const getMergeMethod = () => {
return mergeMethods[input]
}

const parseCommaSeparatedValue = (value) => {
return value.split(',').map(el => el.trim() );
}

exports.getInputs = () => ({
GITHUB_TOKEN: core.getInput('github-token', { required: true }),
MERGE_METHOD: getMergeMethod(),
EXCLUDE_PKGS: core.getInput('exclude') || [],
EXCLUDE_PKGS: parseCommaSeparatedValue(core.getInput('exclude')) || [],
MERGE_COMMENT: core.getInput('merge-comment') || '',
APPROVE_ONLY: /true/i.test(core.getInput('approve-only')),
API_URL: core.getInput('api-url'),
Expand Down
6 changes: 5 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ const getMergeMethod = () => {
return mergeMethods[input]
}

const parseCommaSeparatedValue = (value) => {
return value.split(',').map(el => el.trim());
}

exports.getInputs = () => ({
GITHUB_TOKEN: core.getInput('github-token', { required: true }),
MERGE_METHOD: getMergeMethod(),
EXCLUDE_PKGS: core.getInput('exclude') || [],
EXCLUDE_PKGS: parseCommaSeparatedValue(core.getInput('exclude')) || [],
MERGE_COMMENT: core.getInput('merge-comment') || '',
APPROVE_ONLY: /true/i.test(core.getInput('approve-only')),
API_URL: core.getInput('api-url'),
Expand Down

0 comments on commit e8459a6

Please sign in to comment.