Skip to content

Commit

Permalink
text updates and byRepos command
Browse files Browse the repository at this point in the history
  • Loading branch information
amenocal committed Dec 16, 2024
1 parent 0ec6558 commit 1810d0f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions pkg/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -125,5 +130,6 @@ func SyncTeamsByRepo() {
team.CreateTeam()

}
createTeamsSpinnerSuccess.UpdateText("Team creation process completed")
createTeamsSpinnerSuccess.Success()
}

0 comments on commit 1810d0f

Please sign in to comment.