-
Notifications
You must be signed in to change notification settings - Fork 4
/
post-deploy
executable file
·35 lines (30 loc) · 916 Bytes
/
post-deploy
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
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP=$1;
if [[ -f "$DOKKU_ROOT/$APP/ENV" ]]; then
CURL_OPTS=" --data deployment[user]=dokku"
while read line
do
key=$(echo ${line%%=*} | sed 's/export\s//g')
val=${line##*=}
if [[ ! -z "$val" ]]; then
case $key in
NEW_RELIC_APP_NAME)
CURL_OPTS+=" --data deployment[app_name]=${val//\'/}";
;;
NEW_RELIC_API_KEY)
CURL_OPTS+=" --header x-api-key:${val//\'/}";
;;
esac
fi
done < $DOKKU_ROOT/$APP/ENV;
if [[ ! -z "$CURL_OPTS" ]]; then
http_status=`curl --include --silent $CURL_OPTS https://api.newrelic.com/deployments.xml | grep HTTP/1.1 | awk {'print $2'}`
if [ $http_status -ne 201 ]; then
echo "New Relic: Deployment notification failed."
else
echo "New Relic: Deployment notification submited."
fi
fi
fi
# vim: set ts=2 sw=2: