platform-samples icon indicating copy to clipboard operation
platform-samples copied to clipboard

Script to add all organization repos to a team

Open nathos opened this issue 8 years ago • 4 comments

It would be useful to have a script that:

  1. Gets a list of organization-owned repos
  2. Adds all of those repos to a specified team

Alternatively, it might be better to allow the user to specify a list of repos instead, passing it to the command.

nathos avatar Aug 26 '15 13:08 nathos

@nathos: https://github.com/github/platform-samples/pull/97 would be a start (contains a script that lists all repos of an org). If we decided to include groovy examples, I can also add the code to add them all to a team

jonico avatar Aug 18 '16 12:08 jonico

Example with node api (https://github.com/octokit/rest.js/)

      const orga = 'your-orga';
      const repos = await this.githubApi.repos.listForOrg({ org: orga });

      for(let repo of repos.data) {
        try {
          console.log(`Adding: ${repo.name}`);
          this.githubApi.teams.addOrUpdateRepo({
            team_id: 860,
            owner: orga,
            repo: repo.name,
            permission: "push"
          });
        } catch (e) {
          console.error(e.message);
        }
      }

BlackDark avatar May 02 '19 09:05 BlackDark

Or how about just making the interface for adding repositories better than one repository at a time, 4 clicks/keystroke per repository? This UI is ridiculous!

brianjmurrell avatar Feb 25 '22 16:02 brianjmurrell

I made it less painful utilizing gh (make sure you use token with sufficient permissions) https://gist.github.com/narze/2c2e141f03daea2c23fc5795107d41d4

narze avatar Jul 22 '22 08:07 narze