Skip to content

Instantly share code, notes, and snippets.

@adidonato
Created June 28, 2019 12:56
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 adidonato/5c21795600ab8c21c93706f701727f0e to your computer and use it in GitHub Desktop.
Save adidonato/5c21795600ab8c21c93706f701727f0e to your computer and use it in GitHub Desktop.
#!/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