diff --git a/action.yml b/action.yml index ffd8882..b2ba38e 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,10 @@ name: GitHub Workflow Metrics description: TODO inputs: + label: + description: The label for GitHub issues that the GitHub Action creates + required: false + default: github-workflows-metrics token: description: The GitHub token used to create an authenticated client required: false diff --git a/dist/index.js b/dist/index.js index 6ecf7a7..82d17c6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -29243,6 +29243,9 @@ class Input { get repo() { return this.ctx.repo.repo; } + get label() { + return this.getInputFn("label"); + } get token() { return this.getInputFn("token", { required: true }); } @@ -29296,7 +29299,7 @@ const main = async () => { const runs = await repository.getWorkflowRuns(w); return new MermaidXYChart(w, runs); })); - const issueContent = new GitHubIssueContent(charts, `GitHub Workflow Metrics on ${now.toDateString()}`); + const issueContent = new GitHubIssueContent(charts, `GitHub Workflow Metrics on ${now.toDateString()}`, [], [input.label]); await repository.createIssue(issueContent); }; /* harmony default export */ const src_main = (main); diff --git a/src/Input.ts b/src/Input.ts index 329aa6b..b0d6c3f 100644 --- a/src/Input.ts +++ b/src/Input.ts @@ -19,6 +19,10 @@ export class Input { return this.ctx.repo.repo; } + get label(): string { + return this.getInputFn("label"); + } + get token(): string { return this.getInputFn("token", { required: true }); } diff --git a/src/main.ts b/src/main.ts index 5923d5f..779df4f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,6 +19,8 @@ const main = async () => { const issueContent = new GitHubIssueContent( charts, `GitHub Workflow Metrics on ${now.toDateString()}`, + [], + [input.label], ); await repository.createIssue(issueContent); }; diff --git a/tests/Input.test.ts b/tests/Input.test.ts index 4f406a2..5748c33 100644 --- a/tests/Input.test.ts +++ b/tests/Input.test.ts @@ -13,10 +13,20 @@ describe("Input", () => { owner: "yykamei", repo: "test-repo", }); - const getInput = vi.fn(() => "my-token"); + const getInput = vi.fn((key: string) => { + switch (key) { + case "token": + return "my-token"; + case "label": + return "github-workflows-metrics"; + default: + throw new Error("Unsupported key"); + } + }); const input = new Input(context, getInput); expect(input.owner).toEqual("yykamei"); expect(input.repo).toEqual("test-repo"); + expect(input.label).toEqual("github-workflows-metrics"); expect(input.token).toEqual("my-token"); }); });