diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1daf44a2..440f7584 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,3 +19,4 @@ jobs: - uses: fastify/github-action-merge-dependabot@main with: github-token: ${{ secrets.GITHUB_TOKEN }} + target: minor diff --git a/README.md b/README.md index 79b9d2f4..76ecb2ee 100644 --- a/README.md +++ b/README.md @@ -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` @@ -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 diff --git a/dist/index.js b/dist/index.js index a7cbb846..99932a8b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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); @@ -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 @@ -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 @@ -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 /***/ }), @@ -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'), diff --git a/package-lock.json b/package-lock.json index bdc7a6d5..d6d6a0cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "@actions/core": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.4.0.tgz", - "integrity": "sha512-CGx2ilGq5i7zSLgiiGUtBCxhRRxibJYU6Fim0Q1Wg2aQL2LTnF27zbqZOrxfvFQ55eSBW0L8uVStgtKMpa0Qlg==" + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.5.0.tgz", + "integrity": "sha512-eDOLH1Nq9zh+PJlYLqEMkS/jLQxhksPNmUGNBHfa4G+tQmnIhzpctxmchETtVGyBOvXgOVVpYuE40+eS4cUnwQ==" }, "@actions/github": { "version": "5.0.0", @@ -629,9 +629,9 @@ } }, "@vercel/ncc": { - "version": "0.29.0", - "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.29.0.tgz", - "integrity": "sha512-p+sB835wOSDdgm2mgFgSOcXJF84AqZ+vBEnnGS0sm8veA92Hia7sqH0qEnqeFilPl+cXtxbdh2er+WdlfbVCZA==", + "version": "0.31.1", + "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.31.1.tgz", + "integrity": "sha512-g0FAxwdViI6UzsiVz5HssIHqjcPa1EHL6h+2dcJD893SoCJaGdqqgUF09xnMW6goWnnhbLvgiKlgJWrJa+7qYA==", "dev": true }, "acorn": { @@ -1688,9 +1688,9 @@ } }, "husky": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.1.tgz", - "integrity": "sha512-gceRaITVZ+cJH9sNHqx5tFwbzlLCVxtVZcusME8JYQ8Edy5mpGDOqD8QBCdMhpyo9a+JXddnujQ4rpY2Ff9SJA==", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.2.tgz", + "integrity": "sha512-8yKEWNX4z2YsofXAMT7KvA1g8p+GxtB1ffV8XtpAEGuXNAbCV5wdNKH+qTpw8SM9fh4aMPDR+yQuKfgnreyZlg==", "dev": true }, "ignore": { @@ -2157,9 +2157,9 @@ "dev": true }, "node-fetch": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.2.tgz", + "integrity": "sha512-aLoxToI6RfZ+0NOjmWAgn9+LEd30YCkJKFSyWacNZdEKTit/ZMcKjGkTRo8uWEsnIb/hfKecNPEbln02PdWbcA==" }, "node-preload": { "version": "0.2.1", @@ -2396,9 +2396,9 @@ "dev": true }, "prettier": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.2.tgz", - "integrity": "sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz", + "integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==", "dev": true }, "process-on-spawn": { diff --git a/package.json b/package.json index 303a45f3..0859ee6b 100644 --- a/package.json +++ b/package.json @@ -26,16 +26,16 @@ }, "homepage": "https://github.com/fastify/github-action-merge-dependabot#readme", "dependencies": { - "@actions/core": "^1.4.0", + "@actions/core": "^1.5.0", "@actions/github": "^5.0.0", - "node-fetch": "^2.6.1", + "node-fetch": "^2.6.2", "semver": "^7.3.5" }, "devDependencies": { - "@vercel/ncc": "^0.29.0", + "@vercel/ncc": "^0.31.1", "eslint": "^7.32.0", - "husky": "^7.0.1", - "prettier": "^2.3.2", + "husky": "^7.0.2", + "prettier": "^2.4.1", "tap": "^15.0.9" } } diff --git a/src/util.js b/src/util.js index c95a1766..b92b0f4d 100644 --- a/src/util.js +++ b/src/util.js @@ -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'),