File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
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=" xxxx"
17
+ PATTOKEN=" xxxx"
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
+ done
32
+
33
+ if [ $ERROR_CODE -ne 0 ]; then
34
+ echo " Team creation failed! Please verify validity of supplied configurations."
35
+ exit 1
36
+ else
37
+ echo " Teams succesfully created!"
38
+ fi
39
+
40
+
You can’t perform that action at this time.
0 commit comments