From 2c4b84b143b8aba33d0ed3a15cbf85ffa9c37c6b Mon Sep 17 00:00:00 2001 From: AkkeyLab <17640999+AkkeyLab@users.noreply.github.com> Date: Sun, 5 Feb 2023 18:26:32 +0900 Subject: [PATCH 1/2] Add node id to outputs --- README.md | 2 +- action.yml | 2 ++ src/helpers.ts | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85d259f..6c8ad6d 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ steps: ### Outputs -If you need the number or URL of the issue that was created for another Action, you can use the `number` or `url` outputs, respectively. For example: +If you need the number or URL of the issue that was created for another Action, you can use the `number` or `url` outputs, respectively. The `node id` is useful if another action uses the [GraphQL API](https://docs.github.com/en/graphql/reference). For example: ```yaml steps: diff --git a/action.yml b/action.yml index 5861a6e..b8022e8 100644 --- a/action.yml +++ b/action.yml @@ -29,3 +29,5 @@ outputs: description: Number of the issue that was created url: description: URL of the issue that was created + id: + description: node-id of the issue that was created diff --git a/src/helpers.ts b/src/helpers.ts index 3e503f5..2d3be52 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -16,10 +16,11 @@ export type FrontMatterAttributes = z.infer; export function setOutputs( tools: Toolkit, - issue: { number: number; html_url: string } + issue: { number: number; html_url: string; node_id: string } ) { tools.outputs.number = String(issue.number); tools.outputs.url = issue.html_url; + tools.outputs.id = issue.node_id; } export function listToArray(list?: string[] | string) { From f58da8a7496c753df3bc7eeef21f07f0eb6193b7 Mon Sep 17 00:00:00 2001 From: AkkeyLab <17640999+AkkeyLab@users.noreply.github.com> Date: Sun, 5 Feb 2023 19:07:39 +0900 Subject: [PATCH 2/2] Update test code --- tests/index.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/index.test.ts b/tests/index.test.ts index 6db1df5..c986803 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -38,6 +38,7 @@ describe("create-an-issue", () => { title: body.title, number: 1, html_url: "www", + node_id: "node", }; }); @@ -57,9 +58,10 @@ describe("create-an-issue", () => { expect((tools.log.success as any).mock.calls).toMatchSnapshot(); // Verify that the outputs were set - expect(core.setOutput).toHaveBeenCalledTimes(2); + expect(core.setOutput).toHaveBeenCalledTimes(3); expect(core.setOutput).toHaveBeenCalledWith("url", "www"); expect(core.setOutput).toHaveBeenCalledWith("number", "1"); + expect(core.setOutput).toHaveBeenCalledWith("id", "node"); }); it("creates a new issue from a different template", async () => { @@ -143,6 +145,7 @@ describe("create-an-issue", () => { title: body.title, number: 1, html_url: "www", + node_id: "node", }; });