Skip to content

Commit 9e492c6

Browse files
committed
Add a script to automate the GitHub webhook configuration
After doing this manually for a couple the externalized Fiji plugins, it got boring. Hence this script. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 1e7fd25 commit 9e492c6

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

add-default-github-hooks.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
# Use this script to add the IRC and Jenkins webhooks to the GitHub repositories.
4+
# You will need to add credentials to your $HOME/.netrc for this to work.
5+
6+
die () {
7+
echo "$*" >&2
8+
exit 1
9+
}
10+
11+
test $# = 1 ||
12+
die "Usage: $0 <org>/<repository>"
13+
14+
repository="$1"
15+
16+
url="https://api.github.com/repos/$repository/hooks"
17+
hooks="$(curl --netrc "$url")"
18+
19+
# IRC
20+
if ! echo "$hooks" | grep '^ "name": "irc",$'
21+
then
22+
echo "Adding IRC hook"
23+
curl --netrc -XPOST -d '{"name":"irc","active":true,"events":["push","pull_request"],"config":{"server":"irc.freenode.net","port":"6667","room":"#imagejdev","message_without_join":"1","notice":"1"}}' "$url"
24+
fi
25+
26+
# Jenkins
27+
if ! echo "$hooks" | grep '^ "name": "jenkinsgit",$'
28+
then
29+
echo "Adding Jenkins hook"
30+
curl --netrc -XPOST -d '{"name":"jenkinsgit","active":true,"events":["push"],"config":{"jenkins_url":"http://jenkins.imagej.net/"}}' "$url"
31+
fi

0 commit comments

Comments
 (0)