First, you need to generate a personal access token (PAT) on your GitHub account that has permissions to manage team memberships. Then, you can use the following Bash script to automate the process:
#!/bin/bash
# Set variables
ORG_NAME="your-organization-name"
TEAM_NAME="your-team-name"
PAT="your-personal-access-token"
# Read a file containing a list of usernames (one per line)
while read -r USERNAME; do
# Add the user to the team
curl -X PUT -H "Authorization: token $PAT" "https://api.github.com/orgs/$ORG_NAME/teams/$TEAM_NAME/memberships/$USERNAME"
done < usernames.txt
Replace your-organization-name
, your-team-name
, your-personal-access-token
, and usernames.txt
with your own values. The usernames.txt
file should contain a list of usernames (one per line) that you want to add to the team.
Save the script to a file (e.g. add-team-members.sh
) and make it executable using chmod +x add-team-members.sh
. Then, run the script with ./add-team-members.sh
to add the users to the team.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-03-10 11:00:00 +0000
Seen: 11 times
Last updated: Oct 10 '22