Created
April 12, 2017 04:20
-
-
Save zaemyung/97f8262f643d01a11aabd84feddbc492 to your computer and use it in GitHub Desktop.
Post a notification to slack with the username as the name of the current directory
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 | |
function post_to_slack () { | |
PROC_PATH=${PWD##*/} | |
SLACK_MESSAGE="\`\`\`$1\`\`\`" | |
SLACK_URL=https://hooks.slack.com/services/{hook_address_here} | |
case "$2" in | |
INFO) | |
SLACK_ICON=':monkey_face:' | |
;; | |
WARNING) | |
SLACK_ICON=':warning:' | |
;; | |
ERROR) | |
SLACK_ICON=':bangbang:' | |
;; | |
*) | |
SLACK_ICON=':slack:' | |
;; | |
esac | |
curl -X POST --data "payload={\"username\":\"${PROC_PATH}\", \"icon_emoji\":\"${SLACK_ICON}\", \"text\":\"${SLACK_MESSAGE}\"}" ${SLACK_URL} | |
} | |
post_to_slack "Process has just ended!" "INFO" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment