Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add head_repo and head_owner outputs #356

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 15 additions & 0 deletions src/PullRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ interface PullRequestDetailsResponse {
oid: string;
};
};
headRepository: {
name: string;
owner: {
login: string;
};
};
};
};
}
Expand All @@ -38,6 +44,7 @@ export async function pullRequestDetails(token: string) {
pullRequest: {
baseRef,
headRef,
headRepository,
},
},
} = await client.graphql<PullRequestDetailsResponse>(
Expand All @@ -57,6 +64,12 @@ export async function pullRequestDetails(token: string) {
oid
}
}
headRepository {
name
owner {
login
}
}
}
}
}
Expand All @@ -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,
};
}
4 changes: 4 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down