forked from iloveitaly/dokku-rollbar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-deploy
executable file
·31 lines (25 loc) · 1.23 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
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"
SENTRY_AUTH_TOKEN=$(dokku config:get "$APP" SENTRY_AUTH_TOKEN || echo)
ORGANIZATION=$(dokku config:get "$APP" SENTRY_ORGANIZATION || echo)
GIT_REV=$(dokku config:get "$APP" GIT_REV || echo "$GIT_REV")
if [[ $SENTRY_AUTH_TOKEN ]]; then
echo "-----> Notifying Sentry ..."
ENVIRONMENT=$(
dokku config:get "$APP" SENTRY_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`
SENTRY_RESULT=$(#sentry-cli --auth-token "$SENTRY_AUTH_TOKEN" releases --org "$ORGANIZATION" set-commits "$REVISION" --auto && \
sentry-cli --auth-token "$SENTRY_AUTH_TOKEN" releases --org "$ORGANIZATION" deploys "$REVISION" new -e "$ENVIRONMENT")
echo " ${SENTRY_RESULT}"
fi