diff --git a/README.md b/README.md index bb65a85..130ccb7 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This action has three required inputs; `labels`, `mode` and `count` | Name | Description | Required | Default | | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | ------------------- | -| `labels` | Comma separated list of labels to match | true | +| `labels` | Comma or new line separated list of labels to match | true | | `mode` | The mode of comparison to use. One of: exactly, minimum, maximum | true | | `count` | The required number of labels to match | true | | `token` | The GitHub token to use when calling the API | false | ${{ github.token }} | diff --git a/index.js b/index.js index 8326ff8..351558e 100644 --- a/index.js +++ b/index.js @@ -22,6 +22,8 @@ async function action() { const count = parseInt(core.getInput("count", { required: true }), 10); const providedLabels = core .getInput("labels", { required: true }) + .split("\n") + .join(",") .split(",") .map((l) => l.trim()) .filter((r) => r); diff --git a/index.test.js b/index.test.js index 91c6e2a..ebc7913 100644 --- a/index.test.js +++ b/index.test.js @@ -315,6 +315,34 @@ describe("Required Labels", () => { expect(core.setOutput).toBeCalledWith("status", "success"); expect(core.setOutput).toBeCalledWith("labels", "bug"); }); + + it("supports multiple lines in INPUT_LABELS", async () => { + restoreTest = mockPr({ + INPUT_LABELS: "enhancement\nbug", + INPUT_MODE: "exactly", + INPUT_COUNT: "1", + }); + mockLabels(["bug"]); + + await action(); + expect(core.setOutput).toBeCalledTimes(2); + expect(core.setOutput).toBeCalledWith("status", "success"); + expect(core.setOutput).toBeCalledWith("labels", "bug"); + }); + + it("supports multiple lines with commas in INPUT_LABELS", async () => { + restoreTest = mockPr({ + INPUT_LABELS: "enhancement,\nbug", + INPUT_MODE: "exactly", + INPUT_COUNT: "1", + }); + mockLabels(["bug"]); + + await action(); + expect(core.setOutput).toBeCalledTimes(2); + expect(core.setOutput).toBeCalledWith("status", "success"); + expect(core.setOutput).toBeCalledWith("labels", "bug"); + }); }); describe("configurable exit code", () => {