mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 01:27:41 +00:00
fix(integrations): improved github repos fetching
This commit is contained in:
@@ -242,37 +242,12 @@ const getAppsGithub = async ({ accessToken }: { accessToken: string }) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const octokit = new Octokit({
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||||
|
const repos = (await new Octokit({
|
||||||
auth: accessToken
|
auth: accessToken
|
||||||
});
|
}).paginate("GET /user/repos{?visibility,affiliation,type,sort,direction,per_page,page,since,before}", {
|
||||||
|
per_page: 100
|
||||||
const getAllRepos = async () => {
|
})) as GitHubApp[];
|
||||||
let repos: GitHubApp[] = [];
|
|
||||||
let page = 1;
|
|
||||||
const perPage = 100;
|
|
||||||
let hasMore = true;
|
|
||||||
|
|
||||||
while (hasMore) {
|
|
||||||
const response = await octokit.request(
|
|
||||||
"GET /user/repos{?visibility,affiliation,type,sort,direction,per_page,page,since,before}",
|
|
||||||
{
|
|
||||||
per_page: perPage,
|
|
||||||
page
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if ((response.data as GitHubApp[]).length > 0) {
|
|
||||||
repos = repos.concat(response.data as GitHubApp[]);
|
|
||||||
page += 1;
|
|
||||||
} else {
|
|
||||||
hasMore = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return repos;
|
|
||||||
};
|
|
||||||
|
|
||||||
const repos = await getAllRepos();
|
|
||||||
|
|
||||||
const apps = repos
|
const apps = repos
|
||||||
.filter((a: GitHubApp) => a.permissions.admin === true)
|
.filter((a: GitHubApp) => a.permissions.admin === true)
|
||||||
|
|||||||
Reference in New Issue
Block a user