Skip to content

Commit c4c38db

Browse files
authored
Use /user/repos for org repo options (#2118)
* Filter GitHub repo options to org repos * Log skipped GitHub org repos on SSO/permission errors * Add owner type to GitHubRepo type
1 parent ebc7d79 commit c4c38db

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

packages/integration-platform/src/manifests/github/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface GitHubRepo {
1515
html_url: string;
1616
private: boolean;
1717
default_branch: string;
18-
owner: { login: string };
18+
owner: { login: string; type?: 'User' | 'Organization' };
1919
security_and_analysis?: {
2020
advanced_security?: { status: 'enabled' | 'disabled' };
2121
dependabot_security_updates?: { status: 'enabled' | 'disabled' };

packages/integration-platform/src/manifests/github/variables.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ export const targetReposVariable: CheckVariable = {
4040
};
4141

4242
try {
43-
const repos = await ctx.fetchAllPages<GitHubRepo>(
43+
const allAccessibleRepos = await ctx.fetchAllPages<GitHubRepo>(
4444
'/user/repos?affiliation=owner,collaborator,organization_member&visibility=all',
4545
);
46-
for (const repo of repos) {
46+
const orgRepos = allAccessibleRepos.filter(
47+
(repo) => repo.owner?.type === 'Organization',
48+
);
49+
for (const repo of orgRepos) {
4750
addRepo(repo);
4851
}
4952
} catch (error) {
@@ -68,6 +71,9 @@ export const targetReposVariable: CheckVariable = {
6871
errorStr.includes('SAML') ||
6972
errorStr.includes('Forbidden')
7073
) {
74+
console.warn(
75+
`Skipping organization ${org.login} due to SSO/permission error: ${errorStr}`,
76+
);
7177
continue;
7278
}
7379
// Re-throw other errors

0 commit comments

Comments
 (0)