//native
/**
* Create Pull Request Review
* Approve, request changes on, or comment on a pull request. REQUEST_CHANGES and COMMENT need a body.
*/
export async function main(
auth: RT.Github,
owner: string,
repo: string,
pull_number: number,
event: "APPROVE" | "REQUEST_CHANGES" | "COMMENT",
body: string | undefined,
commit_id: string | undefined
) {
const response = await fetch(
`https://api.github.com/repos/${owner}/${repo}/pulls/${pull_number}/reviews`,
{
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
},
body: JSON.stringify({ event, body, commit_id }),
}
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 2 hours ago