From d869569ad6a12c563a81d3c7f6097132b36d7f7e Mon Sep 17 00:00:00 2001 From: Kareem Morsy Date: Tue, 9 May 2023 14:06:19 +0300 Subject: [PATCH] Add `head_repo` and `head_owner` outputs --- README.md | 2 ++ action.yml | 4 ++++ src/PullRequests.ts | 15 +++++++++++++++ src/main.ts | 4 ++++ 4 files changed, 25 insertions(+) diff --git a/README.md b/README.md index 9ea2690..3a962e3 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,8 @@ Name | Decription `base_sha` | The head sha of the branch the pull request will merge into. `head_ref` | The name of the pull request branch the comment belongs to. `head_sha` | The head sha of the pull request branch the comment belongs to. +`head_owner` | The owner of the pull request branch the comment belongs to. +`head_repo` | The repository of the pull request branch the comment belongs to. ## License diff --git a/action.yml b/action.yml index a84e2bb..55e723c 100644 --- a/action.yml +++ b/action.yml @@ -23,6 +23,10 @@ outputs: description: "The name of the pull request branch the comment belongs to." head_sha: description: "The head sha of the pull request branch the comment belongs to." + head_owner: + description: "The owner of the pull request branch the comment belongs to." + head_repo: + description: "The repository of the pull request branch the comment belongs to." runs: using: "node16" diff --git a/src/PullRequests.ts b/src/PullRequests.ts index 59c4b1d..6be6714 100644 --- a/src/PullRequests.ts +++ b/src/PullRequests.ts @@ -15,6 +15,12 @@ interface PullRequestDetailsResponse { oid: string; }; }; + headRepository: { + name: string; + owner: { + login: string; + }; + }; }; }; } @@ -38,6 +44,7 @@ export async function pullRequestDetails(token: string) { pullRequest: { baseRef, headRef, + headRepository, }, }, } = await client.graphql( @@ -57,6 +64,12 @@ export async function pullRequestDetails(token: string) { oid } } + headRepository { + name + owner { + login + } + } } } } @@ -72,5 +85,7 @@ export async function pullRequestDetails(token: string) { base_sha: baseRef.target.oid, head_ref: headRef.name, head_sha: headRef.target.oid, + head_repo: headRepository.name, + head_owner: headRepository.owner.login, }; } diff --git a/src/main.ts b/src/main.ts index 4ed4b8b..2576286 100644 --- a/src/main.ts +++ b/src/main.ts @@ -15,12 +15,16 @@ export async function run() { base_sha, head_ref, head_sha, + head_repo, + head_owner, } = await pullRequestDetails(token); setOutput("base_ref", base_ref); setOutput("base_sha", base_sha); setOutput("head_ref", head_ref); setOutput("head_sha", head_sha); + setOutput("head_repo", head_repo); + setOutput("head_owner", head_owner); } catch (error) { if (error instanceof Error) { setFailed(error.message);