Created
June 28, 2019 12:56
-
-
Save adidonato/5c21795600ab8c21c93706f701727f0e to your computer and use it in GitHub Desktop.
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 () { | |
# format message as a code block ```${msg}``` | |
SLACK_MESSAGE="\`\`\`$1\`\`\`" | |
SLACK_URL= # [URL of The Channel you want to post to] | |
case "$2" in | |
INFO) | |
SLACK_ICON=':slack:' | |
;; | |
WARNING) | |
SLACK_ICON=':warning:' | |
;; | |
ERROR) | |
SLACK_ICON=':bangbang:' | |
;; | |
*) | |
SLACK_ICON=':slack:' | |
;; | |
esac | |
curl -X POST --data "payload={\"text\": \"${SLACK_ICON} ${SLACK_MESSAGE}\"}" ${SLACK_URL} | |
} | |
"$@" # will expand to the arguments of the command line you specify |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment