Created
March 4, 2020 19:28
-
-
Save nagataka/8062d9a0ce0e1fdaaa0176ac902140bc to your computer and use it in GitHub Desktop.
Send a slack notification
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 | |
set -eu | |
### Incoming WebHooks URL | |
WEBHOOKURL="https://hooks.slack.com/services/FILL_YOUR_WEBHOOKURL" | |
### channel | |
CHANNEL=${CHANNEL:-"#notifications"} | |
### sender name | |
BOTNAME=${BOTNAME:-"notifyme-bot"} | |
# BOTNAME=${BOTNAME:-"${HOSTNAME}"} | |
### slack icon | |
FACEICON=${FACEICON:-":ghost:"} | |
### user_id | |
USERID="Uxxxxxxxx" # User your user_id (not user name) | |
#################### Config payload #################### | |
PAYLOAD=`cat << EOS | |
payload={ | |
"channel": "${CHANNEL}", | |
"username": "${BOTNAME}", | |
"text": "Hey <@${USERID}> your code just finished running", | |
"icon_emoji": "${FACEICON}" | |
} | |
EOS` | |
# Send the payload | |
curl -X POST --data-urlencode "$PAYLOAD" "${WEBHOOKURL}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment