Skip to content

Instantly share code, notes, and snippets.

@Danyboy
Created July 24, 2019 10:28
Show Gist options
  • Save Danyboy/e8f3ae7d55e71ae7fda5d68edf1728d0 to your computer and use it in GitHub Desktop.
Save Danyboy/e8f3ae7d55e71ae7fda5d68edf1728d0 to your computer and use it in GitHub Desktop.
test-channel-name-ios
#!/usr/bin/env bash
# Usage:
#
# Copy text to file ./test-channel-name-ios.sh
# run
# chmod a+x test-channel-name-ios.sh
#
# Start script with channel name and token
#
# ./test-channel-name-ios.sh "channel: deploy" "https://hooks.slack.com/services/TOKEN"
# example:
# ./test-channel-name-ios.sh "uptime-log" "https://hooks.slack.com/services/TOKEN"
channel="${1}"
hook="${2}"
color="good"
read -d '' shortTruePayload1Team << EOF
{
"channel": "#${channel}",
"link_names": true,
"attachments": [
{
"color": "#36a64f",
"title": "36 unresolved incidents notified",
"footer": "test-channel-name-ios",
"fields": [
{
"value": "Academy team: 1",
"short": true
},
{
"value": "#academy-team-alerts",
"short": true
}
]
}
]
}
EOF
read -d '' shortFalsePayload1Team << EOF
{
"channel": "#${channel}",
"link_names": true,
"attachments": [
{
"color": "#36a64f",
"title": "36 unresolved incidents notified",
"footer": "test-channel-name-ios",
"fields": [
{
"value": "Academy team: 1",
"short": false
},
{
"value": "#academy-team-alerts",
"short": false
}
]
}
]
}
EOF
read -d '' shortTruePayload4Teams << EOF
{
"channel": "#${channel}",
"link_names": true,
"attachments": [
{
"color": "#36a64f",
"title": "36 unresolved incidents notified",
"footer": "test-channel-name-ios",
"fields": [
{
"value": "Red team: 1",
"short": true
},
{
"value": "#red-team-alerts",
"short": true
},
{
"value": "Blue team: 1",
"short": true
},
{
"value": "#blue-team-alerts",
"short": true
},
{
"value": "Academy team: 1",
"short": true
},
{
"value": "#academy-team-alerts",
"short": true
}
]
}
]
}
EOF
curl \
--silent \
--output /dev/null \
-X POST \
-H 'Content-type: application/json' \
--data "${shortTruePayload1Team}" ${hook}
curl \
--silent \
--output /dev/null \
-X POST \
-H 'Content-type: application/json' \
--data "${shortFalsePayload1Team}" ${hook}
curl \
--silent \
-X POST \
-H 'Content-type: application/json' \
--data "${shortTruePayload4Teams}" ${hook}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment