-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-repos.sh
executable file
·38 lines (27 loc) · 960 Bytes
/
build-repos.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
set -euo pipefail
if (( $# != 3)); then
printf "Usage: %s <credentials.json> <teams.txt> <admins.txt>\n" "$0" >&2;
exit 1;
fi;
cred_file=$1;
TEAMS=$2
ADMINS=$3
USER=$(cat ${cred_file} | jq --raw-output '.username')
PASS=$(cat ${cred_file} | jq --raw-output '.password')
ORG=$(cat ${cred_file} | jq --raw-output '.organization')
NAMES=$(cat $TEAMS)
for team in $NAMES; do
sleep 1;
curl -i \
-H "application/vnd.github.v3+json" \
--user "${USER}:${PASS}" \
--request POST \
--data "{\"name\": \"${team}\",\"description\": \"ABC team ${team}\",\"homepage\": \"https://github.com\",\"private\": false,\"has_issues\": true,\"has_projects\": true,\"has_wiki\": true}" \
"https://api.github.com/orgs/${ORG}/repos"
done;
./add-admins.sh ${cred_file} ${TEAMS} ${ADMINS}
./initialize-ssh.sh ${cred_file} ${TEAMS}
for team in $NAMES; do
git push -u $team master:master
done