Created
January 26, 2015 08:42
-
-
Save ainoya/3b57826c80c7dba12902 to your computer and use it in GitHub Desktop.
stash_slack.sh
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/bash | |
echo "Notify commits to slack" | |
channel=$2 | |
icon=$4 | |
payload="payload={\"channel\":\"$channel\",\"username\":\"webhookbot\",\"text\":\"Push on ${STASH_REPO_NAME} by ${STASH_USER_NAME} <$STASH_USER_EMAIL>\",\"icon_emoji\":\"$icon\",\"attachments\":[" | |
while read from_ref to_ref ref_name; do | |
message=`git log --format=%B -n 1 ${to_ref}` | |
title="[$STASH_REPO_NAME:$ref_name] <$3/commits/$to_ref|$to_ref>: $message" | |
payload="$payload{\"fallback\":\"$title\",\"pretext\":\"$title\"}," | |
done | |
payload="${payload%?}]}" | |
curl -X POST --data-urlencode "$payload" $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment