github / platform-samples

A public place for all platform sample projects.
Creative Commons Zero v1.0 Universal
1.88k stars 1.73k forks source link

Script to add all organization repos to a team #68

Open nathos opened 9 years ago

nathos commented 9 years ago

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.

jonico commented 8 years ago

@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

BlackDark commented 5 years ago

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);
        }
      }
brianjmurrell commented 2 years ago

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!

narze commented 2 years ago

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