Skip to content

Commit 6d88634

Browse files
Update repos for an Org Team (#37)
If parameters org and team are provided all repos an existing team are being looked up and updated.
1 parent f889d0f commit 6d88634

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,21 @@ Run with the `--verbose` flag to see debug information
5353

5454
## Options
5555

56-
| Flag | Description | Default |
57-
| ------------------------------- | -------------------------------------------------------------- | ------- |
58-
| --pat <token> | GitHub API Token | N/A |
59-
| --repo <name> | The repo to update (format: user/repo) | N/A |
60-
| --user <name> | Update all repos owned by the provided user (example: my-user) | N/A |
61-
| --org <name> | Update all repos in the provided org (example: my-org-name) | N/A |
62-
| --keep-old | Keep the old branch rather than deleting it | false |
63-
| --dry-run | Output log messages only. Do not make any changes | false |
64-
| --list-repos-only | List repos that would be affected, then exit | false |
65-
| --skip-forks | Skips forked repositories | false |
66-
| --skip-update-branch-protection | Skip updating branch protections | false |
67-
| --old | The name of the branch to rename | master |
68-
| --new | The new branch name | main |
69-
| --confirm | Run without prompting for confirmation | false |
56+
| Flag | Description | Default |
57+
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ------- |
58+
| --pat <token> | GitHub API Token | N/A |
59+
| --repo <name> | The repo to update (format: user/repo) | N/A |
60+
| --user <name> | Update all repos owned by the provided user (example: my-user) | N/A |
61+
| --org <name> | Update all repos in the provided org (example: my-org-name) | N/A |
62+
| --team <name> | Update all repos in the provided team (example: my-team-name), only usable in combination with org parameter | N/A |
63+
| --keep-old | Keep the old branch rather than deleting it | false |
64+
| --dry-run | Output log messages only. Do not make any changes | false |
65+
| --list-repos-only | List repos that would be affected, then exit | false |
66+
| --skip-forks | Skips forked repositories | false |
67+
| --skip-update-branch-protection | Skip updating branch protections | false |
68+
| --old | The name of the branch to rename | master |
69+
| --new | The new branch name | main |
70+
| --confirm | Run without prompting for confirmation | false |
7071

7172
## Replacements
7273

bin/github-default-branch

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
description:
1818
"Update all repos in the provided org (example: my-org-name)",
1919
},
20+
team: {
21+
type: "string",
22+
description:
23+
"Update all repos in the provided team (example: my-team-name), only usable in combination with org parameter",
24+
},
2025
"keep-old": {
2126
type: "boolean",
2227
default: false,

src/get-repos.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = async function (args, octokit) {
44
}
55

66
let repos = [];
7-
if (args.org) {
7+
if (args.org && !args.team) {
88
repos = await octokit.paginate(
99
octokit.repos.listForOrg,
1010
{
@@ -15,6 +15,18 @@ module.exports = async function (args, octokit) {
1515
);
1616
}
1717

18+
if (args.org && args.team) {
19+
repos = await octokit.paginate(
20+
octokit.teams.listReposInOrg,
21+
{
22+
org: args.org,
23+
team_slug: args.team,
24+
per_page: 100
25+
},
26+
(response) => response.data
27+
);
28+
}
29+
1830
if (args.user) {
1931
repos = await octokit.paginate(
2032
octokit.repos.listForAuthenticatedUser,

0 commit comments

Comments
 (0)