//native
/**
* Merge Pull Request
* Merge a pull request with a merge commit, squash or rebase. Set sha to make the merge fail if the head moved.
*/
export async function main(
auth: RT.Github,
owner: string,
repo: string,
pull_number: number,
merge_method: "merge" | "squash" | "rebase" | undefined,
commit_title: string | undefined,
commit_message: string | undefined,
sha: string | undefined
) {
const response = await fetch(
`https://api.github.com/repos/${owner}/${repo}/pulls/${pull_number}/merge`,
{
method: "PUT",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
},
body: JSON.stringify({ merge_method, commit_title, commit_message, sha }),
}
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 2 hours ago