(githubId?: string)
| 173 | }; |
| 174 | |
| 175 | export const getGithubRepositories = async (githubId?: string) => { |
| 176 | if (!githubId) { |
| 177 | return []; |
| 178 | } |
| 179 | |
| 180 | const githubProvider = await findGithubById(githubId); |
| 181 | |
| 182 | const octokit = new Octokit({ |
| 183 | authStrategy: createAppAuth, |
| 184 | auth: { |
| 185 | appId: githubProvider.githubAppId, |
| 186 | privateKey: githubProvider.githubPrivateKey, |
| 187 | installationId: githubProvider.githubInstallationId, |
| 188 | }, |
| 189 | }); |
| 190 | |
| 191 | const repositories = (await octokit.paginate( |
| 192 | octokit.rest.apps.listReposAccessibleToInstallation, |
| 193 | )) as unknown as Awaited< |
| 194 | ReturnType<typeof octokit.rest.apps.listReposAccessibleToInstallation> |
| 195 | >["data"]["repositories"]; |
| 196 | |
| 197 | return repositories; |
| 198 | }; |
| 199 | |
| 200 | export const getGithubBranches = async ( |
| 201 | input: z.infer<typeof apiFindGithubBranches>, |
no test coverage detected