diff --git a/misc/hooks/post-receive b/misc/hooks/post-receive new file mode 100644 index 0000000..f4e70e0 --- /dev/null +++ b/misc/hooks/post-receive @@ -0,0 +1,24 @@ +#!/usr/local/bin/bash + +set -x +set -e + +URL=discord-hook + +while read oldrev newrev ref; do + if [[ $ref =~ .*/master$ ]]; then + logmsg="" + commits=$(git rev-list ${oldrev}..${newrev}) + for commit in $commits; do + log=$(git log -1 --pretty=format:'[%h](https://github.com/jorisvink/kore/commit/%H) %cn: %s' $commit) + logmsg="$logmsg $log\\n" + done + + curl -i \ + -H "Accept: application/json" \ + -H "Content-type: application/json" \ + -X POST \ + -d "{\"content\": \"${logmsg}\"}" \ + $URL + fi +done