diff --git a/README.md b/README.md index 5c2a8a5..64f42a2 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ The following inputs are supported | `token` | GitHub Personal Access Token for making API requests. | `false` | `${{ github.token }}` | | `command_script_name` | The package script that runs knip. | `false` | `knip` | | `comment_id` | ID to use when updating the PR comment. Spaces will be replaced with dashes. | `false` | `${{ github.workflow }}-knip-reporter` | +| `annotations` | Annotate the project code with the knip results. | `false` | `true` | | `ignore_result` | Do not fail the action run if knip results are found. | `false` | `false` | ### Issues diff --git a/action.yml b/action.yml index 3513014..d362951 100644 --- a/action.yml +++ b/action.yml @@ -17,8 +17,12 @@ inputs: description: ID to use when updating the PR comment. default: "${{ github.workflow }}-knip-reporter" required: false + annotations: + description: Annotate the project code with the knip results. + default: true + required: false ignore_results: - description: Do not fail the action run if knip results are found + description: Do not fail the action run if knip results are found. default: false required: false runs: diff --git a/src/action.spec.ts b/src/action.spec.ts index d296f66..f418cf3 100644 --- a/src/action.spec.ts +++ b/src/action.spec.ts @@ -37,6 +37,7 @@ describe("Action", () => { case "token": case "command_script_name": case "comment_id": + case "annotations": case "ignore_results": return mockEnvConfig[input]; default: @@ -97,6 +98,13 @@ describe("Action", () => { expect(config.commentId).toStrictEqual("Special-Comment-ID"); }); + it("should load a custom value for annotations", () => { + mockEnvConfig.annotations = "false"; + const config: ActionConfig = getConfig(); + + expect(config.annotations).toStrictEqual(false); + }); + it("should load a custom value for ignoreResults", () => { mockEnvConfig.ignore_results = "true"; const config: ActionConfig = getConfig(); diff --git a/src/action.ts b/src/action.ts index f101cbb..b4a4781 100644 --- a/src/action.ts +++ b/src/action.ts @@ -15,12 +15,17 @@ export interface ActionConfig { commandScriptName: string; /** - * ID to use when updating the PR comment + * ID to use when updating the PR comment. */ commentId: string; /** - * Do not fail the action run if knip results are found + * Annotate the project code with the knip results. + */ + annotations: boolean; + + /** + * Do not fail the action run if knip results are found. */ ignoreResults: boolean; } @@ -30,6 +35,7 @@ export function getConfig(): ActionConfig { token: core.getInput("token", { required: true }), commandScriptName: core.getInput("command_script_name", { required: false }) || "knip", commentId: core.getInput("comment_id", { required: true }).trim().replaceAll(/\s/g, "-"), + annotations: core.getInput("annotations", { required: false }) === "true", ignoreResults: core.getInput("ignore_results", { required: false }) === "true", }; }