Created
July 18, 2012 15:18
-
-
Save jgoodall/3136821 to your computer and use it in GitHub Desktop.
git post-receive hook for sending notifications to notifo
This file contains 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/sh | |
# | |
# Send git commit notifications to [notifo](http://notifo.com/) | |
# read the commands from stdin in the git hook | |
read oldrev newrev refname | |
# name of the repository | |
REPO="GIT REPOSITORY NAME" | |
# use modern curl >= 7.18 | |
CURL='/usr/local/bin/curl' | |
# users to send the notification to | |
# only seem to be able to send one at a time... | |
USERS='user1 user2' | |
# the service registered with notifo and its key | |
SERVICE=git_commit_service_name | |
APIKEY=git_commit_service_api_key | |
# the [notification API](https://api.notifo.com/docs/notifications) | |
URL=https://api.notifo.com/v1/send_notification | |
# get the summary of the last commit | |
summary=`git rev-list -1 --oneline $newrev` | |
# set the message to the latest revision | |
message="${REPO} : ${summary}" | |
# send the command using curl | |
for i in $USERS; do | |
$CURL --silent -k -u $SERVICE:$APIKEY --data-urlencode "to=$i" --data-urlencode "msg=$message" $URL | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment