type Github = {
token: string;
};
/**
* Create an issue
* Any user with pull access to a repository can create an issue.
*/
export async function main(
auth: Github,
owner: string,
repo: string,
body: {
assignee?: string;
assignees?: string[];
body?: string;
labels?: (
| string
| {
color?: string;
description?: string;
id?: number;
name?: string;
[k: string]: unknown;
}
)[];
milestone?: string | number;
title: string | number;
[k: string]: unknown;
}
) {
const url = new URL(`https://api.github.com/repos/${owner}/${repo}/issues`);
const response = await fetch(url, {
method: "POST",
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 367 days ago
type Github = {
token: string;
};
/**
* Create an issue
* Any user with pull access to a repository can create an issue.
*/
export async function main(
auth: Github,
owner: string,
repo: string,
body: {
assignee?: string;
assignees?: string[];
body?: string;
labels?: (
| string
| {
color?: string;
description?: string;
id?: number;
name?: string;
[k: string]: unknown;
}
)[];
milestone?: string | number;
title: string | number;
[k: string]: unknown;
}
) {
const url = new URL(`https://api.github.com/repos/${owner}/${repo}/issues`);
const response = await fetch(url, {
method: "POST",
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 927 days ago