From d6ba4e7c5a27826834954617cfef754694e1ca38 Mon Sep 17 00:00:00 2001 From: Fayorg Date: Sun, 24 Mar 2024 13:16:33 +0100 Subject: [PATCH] add: fetch gh branches --- actions/github/repository.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/actions/github/repository.ts b/actions/github/repository.ts index 7b09aef..742576c 100644 --- a/actions/github/repository.ts +++ b/actions/github/repository.ts @@ -45,4 +45,17 @@ export async function getUserRepository(userId: string, username: string): Promi }).then(res => res.json()); return repositories.repositories as GithubRepository[]; +} + +export async function getRepositoryBranches(userId: string, username: string, repository: string): Promise { + 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[]; } \ No newline at end of file