Skip to content

Update repos for an Org Team #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,21 @@ Run with the `--verbose` flag to see debug information

## Options

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

## Replacements

Expand Down
5 changes: 5 additions & 0 deletions bin/github-default-branch
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
description:
"Update all repos in the provided org (example: my-org-name)",
},
team: {
type: "string",
description:
"Update all repos in the provided team (example: my-team-name), only usable in combination with org parameter",
},
"keep-old": {
type: "boolean",
default: false,
Expand Down
14 changes: 13 additions & 1 deletion src/get-repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = async function (args, octokit) {
}

let repos = [];
if (args.org) {
if (args.org && !args.team) {
repos = await octokit.paginate(
octokit.repos.listForOrg,
{
Expand All @@ -15,6 +15,18 @@ module.exports = async function (args, octokit) {
);
}

if (args.org && args.team) {
repos = await octokit.paginate(
octokit.teams.listReposInOrg,
{
org: args.org,
team_slug: args.team,
per_page: 100
},
(response) => response.data
);
}

if (args.user) {
repos = await octokit.paginate(
octokit.repos.listForAuthenticatedUser,
Expand Down