type Github = {
token: string;
};
/**
* Update a reference
*
*/
export async function main(
auth: Github,
owner: string,
repo: string,
ref: string,
body: { force?: boolean; sha: string; [k: string]: unknown }
) {
const url = new URL(
`https://api.github.com/repos/${owner}/${repo}/git/refs/${ref}`
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 328 days ago