Created
March 10, 2014 18:19
-
-
Save tolleiv/9470916 to your computer and use it in GitHub Desktop.
Autoregistering a hook through a shell script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### ALL SPOTS marked with XXX have to be changed before this runs | |
token="XXX"; # get that from your user settings | |
name="AOEpeople" # the github login name | |
type="orgs" # or "users" | |
list=`curl -s -H "Authorization: token ${token}" "https://api.github.com/${type}/${name}/repos" | grep '"url"' | grep 'repos' | sed -E 's~.*https(.*)",~https\1~'` | |
for repo in $list; do | |
hooks=`curl -s -H "Authorization: token ${token}" "${repo}/hooks" | grep "aoepeople"` | |
echo -n "${repo} " | |
if [ -z "${hooks}" ]; then | |
echo "registering" | |
curl -s -X POST -H "Content-Type: application/json" -H "Authorization: token ${token}" -d '{ "name": "repoactivity", "active": true, "events": [ "*" ], "config": { "url": "XXXX", "content_type": "form" } }' "${repo}/hooks" | |
else | |
echo "ok" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment