Skip to content

Commit 0e0be86

Browse files
committed
code review fix
1 parent ff5a00f commit 0e0be86

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

api/bash/create-teams.sh

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,31 @@
1313
# - ./script.sh
1414

1515
# VARS
16-
ORGNAME="xxxx"
17-
PATTOKEN="xxxx"
18-
TEAMS=("team-name-1" "team-name-2")
16+
orgname="xxx"
17+
pattoken="xxxxxxx"
18+
teams=("team-name-1" "team-name-2")
1919

2020
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\" }"
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
3138
done
39+
echo "Teams succesfully created!"
40+
3241

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
3942

4043

0 commit comments

Comments
 (0)