type Github = {
token: string;
};
/**
* Add or update team repository permissions
* To add a repository to a team or update the team's permission on a repository, the authenticated user must have admin access to the repository, and must be able to see the team.
*/
export async function main(
auth: Github,
org: string,
team_slug: string,
owner: string,
repo: string,
body: { permission?: string; [k: string]: unknown }
) {
const url = new URL(
`https://api.github.com/orgs/${org}/teams/${team_slug}/repos/${owner}/${repo}`
);
const response = await fetch(url, {
method: "PUT",
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.text();
}
Submitted by hugo697 367 days ago
type Github = {
token: string;
};
/**
* Add or update team repository permissions
* To add a repository to a team or update the team's permission on a repository, the authenticated user must have admin access to the repository, and must be able to see the team.
*/
export async function main(
auth: Github,
org: string,
team_slug: string,
owner: string,
repo: string,
body: { permission?: string; [k: string]: unknown }
) {
const url = new URL(
`https://api.github.com/orgs/${org}/teams/${team_slug}/repos/${owner}/${repo}`
);
const response = await fetch(url, {
method: "PUT",
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.text();
}
Submitted by hugo697 927 days ago