Skip to content

Instantly share code, notes, and snippets.

@cmbuckley
Last active June 12, 2019 12:30
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 cmbuckley/cea6a5131aaeed57fb2bb387fe17b0ae to your computer and use it in GitHub Desktop.
Save cmbuckley/cea6a5131aaeed57fb2bb387fe17b0ae to your computer and use it in GitHub Desktop.
Firedrill script
#!/bin/bash
webhook_url="URL HERE"
role=Firedrill
icon=bust_in_silhouette
channel="#lotto-support-3p"
roles=(
"marketing,Marketing:female-technologist::skin-tone-2"
"crm,CRM:male-singer::skin-tone-3"
"core,Core on-call:bearded_person::skin-tone-2"
)
# help message
usage() {
echo "Usage: $prg [-r ROLE] [-c CHANNEL] MESSAGE" >&2
exit 1
}
while getopts ":r:c:" opt; do
case "$opt" in
r)
role=$OPTARG
;;
c)
channel=$OPTARG
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
for r in "${roles[@]}"; do
k=${r%%,*}
v=${r#*,}
[[ "$k" == "$role" ]] && role="${v%%:*}" && icon="${v#*:}"
done
curl -X POST \
--data-urlencode "payload={\"channel\": \"$channel\", \"username\": \"$role\", \"text\": \"$*\", \"icon_emoji\": \":$icon:\"}" \
"$webhook_url"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment