Skip to content

Commit

Permalink
Support label to let a user specify arbitrary label for issue
Browse files Browse the repository at this point in the history
  • Loading branch information
yykamei committed Mar 28, 2024
1 parent 7ca4120 commit 78b7dfc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 4 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const main = async () => {
const issueContent = new GitHubIssueContent(
charts,
`GitHub Workflow Metrics on ${now.toDateString()}`,
[],
[input.label],
);
await repository.createIssue(issueContent);
};
Expand Down
12 changes: 11 additions & 1 deletion tests/Input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});

0 comments on commit 78b7dfc

Please sign in to comment.