//native
/**
* Update Issue
* Update an issue's title, body, state, assignees, labels or milestone. Only the fields you set change; assignees and labels replace the existing lists.
*/
export async function main(
auth: RT.Github,
owner: string,
repo: string,
issue_number: number,
title: string | undefined,
body: string | undefined,
state: "open" | "closed" | undefined,
state_reason: "completed" | "not_planned" | "reopened" | undefined,
assignees: string[] | undefined,
labels: string[] | undefined,
milestone: number | undefined
) {
const response = await fetch(
`https://api.github.com/repos/${owner}/${repo}/issues/${issue_number}`,
{
method: "PATCH",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
},
body: JSON.stringify({
title,
body,
state,
state_reason,
assignees,
labels,
milestone,
}),
}
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 2 hours ago