Skip to content

Instantly share code, notes, and snippets.

@jgoodall
Created July 18, 2012 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgoodall/3136821 to your computer and use it in GitHub Desktop.
Save jgoodall/3136821 to your computer and use it in GitHub Desktop.
git post-receive hook for sending notifications to notifo
#!/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