GitHub: Script to Mass Add Users to a Team
Add users to a GitHub org team programmatically from a CSV file
Overview
If you’ve ever had to add several users to a team in a GitHub organization, you know it can be a pain as it’s one user at a time and multiple clicks per add. This script aims to simplify that by adding users to a GitHub org team programmatically from a CSV file.
The Script
This script is in my github-misc-scripts repo:
Using the Script
Prerequisite: You need to make sure to have the gh cli
installed and authorized (gh auth login
).
- Create a
users.csv
with the list of users to add to the team, one per line, and leave a trailing empty line/whitespace at the end of the file. The file should look like:1 2 3
user1 user2
- From there, it’s pretty simple - run the script, passing in the
users.csv
file, org name, and team name:1
./add-users-to-team-from-list.sh users.csv <org> <team>
Summary
Hopefully this saves you some time in the UI when adding multiple users to a team!
This post is licensed under CC BY 4.0 by the author.