add: fetch gh branches

This commit is contained in:
Elie Baier 2024-03-24 13:16:33 +01:00
parent f57e0eed3c
commit d6ba4e7c5a
1 changed files with 13 additions and 0 deletions

View File

@ -46,3 +46,16 @@ export async function getUserRepository(userId: string, username: string): Promi
return repositories.repositories as GithubRepository[];
}
export async function getRepositoryBranches(userId: string, username: string, repository: string): Promise<string[]> {
const branches = await fetch(`https://api.github.com/repos/${username}/${repository}/branches`, {
headers: {
Authorization: `Bearer ${await getInstallationAccessToken(userId, username)}`,
Accept: "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
},
method: 'GET',
}).then(res => res.json());
return branches.map((branch: { name: string }) => branch.name) as string[];
}