Magnus
Magnus

Reputation: 728

How can I get a list of all repositories in a GitHub organization where I am an admin or collaborator?

I’m a member of the GitHub Organization bigOrg, with ~8000 repositories. I am a collaborator or an administrator for about 50 of them. My GitHub username is magnus. How can I query any of the GitHub APIs and retrieve a list of these ~50 repositories?

Upvotes: 6

Views: 1002

Answers (1)

Magnus
Magnus

Reputation: 728

This doesn't answer the question I asked, but it might be close enough to solve my use case. This GraphQL query seems to return all repositories for which I am a collaborator or administrator but not an owner. Repositories owned by bigOrg are returned, but so are repositories owned by any other organization.

{
  viewer {
    repositories(first: 100, affiliations: [COLLABORATOR, ORGANIZATION_MEMBER]) {
      totalCount
      pageInfo {
        endCursor
        hasNextPage
      }
      nodes{
        url
        name
          owner {
            login
          }
        }
      }
   }
 }

Upvotes: 6

Related Questions