-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheb_deploy_and_notify.sh
51 lines (41 loc) · 1.86 KB
/
eb_deploy_and_notify.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
set -x
export SHA1=`echo ${CIRCLE_SHA1} | cut -c1-7`
export ENV=`echo $1 | rev | cut -d \- -f1 | rev`
function dd_mute() {
if [[ ${DD_MUTE_ID+x} ]]; then
echo "muting DD monitor id: ${DD_MUTE_ID}"
curl -X POST "https://app.datadoghq.com/api/v1/monitor/${DD_MUTE_ID}/mute?api_key=${DD_API_KEY}&application_key=${DD_APP_KEY}"
fi
}
function dd_unmute() {
if [[ ${DD_MUTE_ID+x} ]]; then
echo "un-muting DD monitor id: ${DD_MUTE_ID}"
curl -X POST "https://app.datadoghq.com/api/v1/monitor/${DD_MUTE_ID}/unmute?api_key=${DD_API_KEY}&application_key=${DD_APP_KEY}"
fi
}
function notify() {
if [[ ${ROLLBAR_ACCESS_TOKEN+x} ]]; then
echo "notifying rollbar"
curl https://api.rollbar.com/api/1/deploy/ -F access_token=$ROLLBAR_ACCESS_TOKEN -F environment=$ENV -F revision=$CIRCLE_SHA1 -F local_username=$CIRCLE_USERNAME -F comment="$CIRCLE_BUILD_URL"
fi
}
dd_mute
eb deploy $1 -v --timeout 15
if [ $? -eq 0 ]; then
export SL_COLOR="good"
export SL_TEXT="Success: Deployed ${CIRCLE_BRANCH} (<${CIRCLE_COMPARE_URL}|${SHA1}>) by ${CIRCLE_USERNAME} !!"
export SL_ICON="https://www.cloudbees.com/sites/default/files/eleasticbeanstalk_square.png"
export EXIT=0
notify
else
export SL_COLOR="danger"
export SL_TEXT="Failure: Deploying ${CIRCLE_BRANCH} (<${CIRCLE_COMPARE_URL}|${SHA1}>) by ${CIRCLE_USERNAME} !!"
export SL_ICON="https://www.cloudbees.com/sites/default/files/eleasticbeanstalk_square.png"
export EXIT=1
fi
if [[ ${SLACK_HOOK+x} ]]; then
curl -X POST --data-urlencode 'payload={"username": "Elastic Beanstalk ('"$CIRCLE_PROJECT_REPONAME"')", "icon_url": "'"$SL_ICON"'", "channel": "'"${CHANNEL:-#test}"'", "attachments": [{ "color": "'"$SL_COLOR"'", "text": "'"$SL_TEXT"'", "mrkdwn_in": ["text"] }] }' https://hooks.slack.com/services/${SLACK_HOOK}
fi
dd_unmute
exit $EXIT