Skip to content

Commit c216345

Browse files
authored
Merge pull request github#370 from github/bulk-team-create-scripts
Add script for creating teams in bulk in github orgs
2 parents 59766bc + 0e0be86 commit c216345

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

api/bash/create-teams.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
# Replace the "xxxxx" with the required values
3+
# Author: @ppremk
4+
5+
# Script to create GitHub Teams in bulk on GitHub.com Organization
6+
# PAT Tokens needs to have the correct scope to be able to create teams in an organization
7+
# Teams are added as an Array. Teams are created as stand alone teams. Team relationship is not defined
8+
9+
# To run the script:
10+
#
11+
# - Update VARS section in script
12+
# - chmod +x script.sh
13+
# - ./script.sh
14+
15+
# VARS
16+
orgname="xxx"
17+
pattoken="xxxxxxx"
18+
teams=("team-name-1" "team-name-2")
19+
20+
echo "Bulk creating teams in:"
21+
echo $orgname
22+
23+
for i in "${teams[@]}"
24+
do
25+
curl --request POST \
26+
--url "https://api.github.com/orgs/$orgname/teams" \
27+
--header "accept: application/vnd.github.v3+json" \
28+
--header "authorization: Bearer ${pattoken}" \
29+
--header "content-type: application/json" \
30+
--data "{\"name\": \"$i\", \"privacy\": \"closed\" }" \
31+
-- fail
32+
33+
retVal=$?
34+
if [ $retVal -ne 0 ]; then
35+
echo "Team creation failed! Please verify validity of supplied configurations."
36+
exit 1
37+
fi
38+
done
39+
echo "Teams succesfully created!"
40+
41+
42+
43+

0 commit comments

Comments
 (0)