Created
May 7, 2018 18:29
-
-
Save kas-cor/8a8a9f6f316361b96cee189ba6480642 to your computer and use it in GitHub Desktop.
Git Hook udpate send notify to Slack channel use IFTTT WebHooks
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 | |
| iftttkey="" | |
| iftttevent="" | |
| if [ "$3" = "0000000000000000000000000000000000000000" ]; then | |
| type=delete | |
| else | |
| type=$(git cat-file -t $3) | |
| fi | |
| if [ "$type" = "commit" ]; then | |
| branch=`echo $1 | sed 's|.*/heads/||'` | |
| repo=`echo $(pwd) | sed 's|.*/git/||'` | |
| info=`echo $(git cat-file -p $3) | sed 's|.*committer ||' | tr '<' '(' | tr '>' ')'` | |
| author=`echo $info | sed -r 's/\).+//'` | |
| text=`echo $info | sed 's|.*+0300 ||'` | |
| generate_post_data() | |
| { | |
| cat <<EOF | |
| { | |
| "value1": "Repository $repo, branch $branch", | |
| "value2": "$author)\n$text", | |
| "value3": "$old" | |
| } | |
| EOF | |
| } | |
| curl -s -o /dev/null -X POST -H "Content-Type: application/json" -d "$(generate_post_data)" https://maker.ifttt.com/trigger/$iftttevent/with/key/$iftttkey | |
| fi | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment