-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig
executable file
·48 lines (36 loc) · 1.56 KB
/
config
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
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
set -e
indent() {
c='s/^/ /'
case $(uname) in
Darwin) sed -l "$c";; # mac/bsd sed: -l buffers on line boundaries
*) sed -u "$c";; # unix/gnu sed: -u unbuffered (arbitrary) chunks of data
esac
}
status() {
echo "-----> $*"
}
status "Removing old files"
rm /tmp/repos* /tmp/repo-*
status "Getting repository list"
curl -s -H "Authorization: token ${OAUTH_TOKEN}" https://api.github.com/orgs/etna-alternance/repos?per_page=200 \
| jq '[.[] | {name, has_issues, has_wiki, has_download, default_branch, owner: .owner | {login, id}}]' \
| jq '.[] | {name, has_wiki: false, has_issues: false, default_branch: "master"}' \
> /tmp/repos-patch.json
split -a 3 -l 6 /tmp/repos-patch.json /tmp/repo-
for file in /tmp/repo-{aaf,acg}; do
# for file in /tmp/repo-*; do
name=$(cat "$file" | jq .name | tr -d '"')
status Editing $name
echo Setting global parameters | indent
curl -s -X PATCH -d @$file -H "Content-Type: application/json" -H "Authorization: token ${OAUTH_TOKEN}" https://api.github.com/repos/etna-alternance/$name > /dev/null
echo Deleting existing hooks | indent
curl -s -H "Authorization: token ${OAUTH_TOKEN}" https://api.github.com/repos/etna-alternance/$name/hooks \
| jq .[].url \
| tr -d '"' \
| while read URL; do
curl -s -X DELETE -H "Authorization: token ${OAUTH_TOKEN}" $URL
done
# echo "Add 'dev' team" | indent
# curl -sv -X PUT -H "Authorization: token ${OAUTH_TOKEN}" https://api.github.com/teams/572022/repos/etna-alternance/$name
done