-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpost-deploy
executable file
·35 lines (28 loc) · 1.08 KB
/
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"
ROLLBAR_TOKEN=$(dokku config:get "$APP" ROLLBAR_TOKEN || echo)
GIT_REV=$(dokku config:get "$APP" GIT_REV || echo "$GIT_REV")
if [[ $ROLLBAR_TOKEN ]]; then
echo "-----> Notifying Rollbar ..."
ENVIRONMENT=$(
dokku config:get "$APP" ROLLBAR_ENV ||
dokku config:get "$APP" RAILS_ENV ||
dokku config:get "$APP" RACK_ENV ||
echo 'production'
)
REVISION="$GIT_REV"
if [[ ! $REVISION ]]; then
echo " WARNING: \$GIT_REV is not available - falling back to parsing git commit hash from git log"
echo " On Dokku < 0.12.0, install dokku-git-rev plugin to fix this error. See https://github.com/iloveitaly/dokku-rollbar/issues/4"
REVISION=$(cd $DOKKU_ROOT/$APP && git log -n 1 --pretty=format:"%H" 2>/dev/null)
fi
LOCAL_USERNAME=`whoami`
ROLLBAR_RESULT=$(curl -s https://api.rollbar.com/api/1/deploy/ \
-F access_token=$ROLLBAR_TOKEN \
-F environment=$ENVIRONMENT \
-F revision=$REVISION \
-F local_username=$LOCAL_USERNAME
)
echo " ${ROLLBAR_RESULT}"
fi