From 1810d0fd1aab78e4f98c13b053bc06f9f36c952b Mon Sep 17 00:00:00 2001 From: Alejandro Menocal Date: Mon, 16 Dec 2024 17:33:48 -0600 Subject: [PATCH] text updates and byRepos command --- README.md | 22 ++++++++++++++++++++++ pkg/sync/sync.go | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/README.md b/README.md index 347938e..3f52fe9 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,9 @@ gh extension install mona-actions/gh-migrate-teams ``` +>[!NOTE] +> If setting any environmental variables through this CLI extension, make sure to add the `GHMT` prefix. For example, `GHMT_TOKEN` instead of `TOKEN`. + ## Usage: Export Export team membership, team repository access, and repository collaborator access to CSV files. @@ -44,6 +47,25 @@ Flags: -z, --user-sync string User sync mode. One of: all, disable (default "none") (default "all") ``` +### Sync by Repository List + +You can also sync teams by providing a list of repositories to sync. This is useful when you want to sync a subset of repositories from the source organization to the target organization. + +```bash +Usage: + migrate-teams sync byRepos [flags] + +Flags: + -f, --from-file string File path to use for repository list (default "repositories.txt") + -h, --help help for byRepos + -m, --mapping-file string Mapping file path to use for mapping teams members handles + -k, --skip-teams Skips adding members and repos to teams that already exist to save on API requests (default "false") + -u, --source-hostname string GitHub Enterprise source hostname url (optional) Ex. https://github.example.com + -a, --source-token string Source Organization GitHub token. Scopes: read:org, read:user, user:email + -t, --target-organization string Target Organization to sync teams from + -b, --target-token string Target Organization GitHub token. Scopes: admin:org +``` + ### Mapping File Example A mapping file can be provided to map member handles in case they are different between source and target. diff --git a/pkg/sync/sync.go b/pkg/sync/sync.go index f46af74..39b0d4f 100644 --- a/pkg/sync/sync.go +++ b/pkg/sync/sync.go @@ -109,6 +109,11 @@ func SyncTeamsByRepo() { // Print out how many teams were found: teamsSpinnerSuccess.UpdateText("Fetched a total of " + strconv.Itoa(len(teams)) + " teams with total of " + strconv.Itoa(totalMembers) + " members from the repository list") + if len(teams) == 0 { + teamsSpinnerSuccess.Fail() + return + } + teamsSpinnerSuccess.Success() // Create teams in target organization @@ -125,5 +130,6 @@ func SyncTeamsByRepo() { team.CreateTeam() } + createTeamsSpinnerSuccess.UpdateText("Team creation process completed") createTeamsSpinnerSuccess.Success() }