-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpost-deploy
More file actions
executable file
·30 lines (28 loc) · 1.15 KB
/
post-deploy
File metadata and controls
executable file
·30 lines (28 loc) · 1.15 KB
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
#!/usr/bin/env bash
PLUGIN_BASE_PATH="$PLUGIN_PATH"
if [[ -n $DOKKU_API_VERSION ]]; then
PLUGIN_BASE_PATH="$PLUGIN_ENABLED_PATH"
fi
source "$PLUGIN_BASE_PATH/common/functions"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
set +e
APP="$1"
APP_ROOT="$DOKKU_ROOT/$APP"
API_KEY=$(dokku config:get "$APP" AIRBRAKE_API_KEY)
if [[ $API_KEY ]]; then
cd "$APP_ROOT"
REPO_URL=$(dokku config:get "$APP" AIRBRAKE_REPO_URL || echo "dokku@$(cat "$DOKKU_ROOT/VHOST"):$APP")
BASE_URL=$(dokku config:get "$APP" AIRBRAKE_BASE_URL || echo 'https://airbrake.io')
RAILS_ENV=$(dokku config:get "$APP" RACK_ENV || dokku config:get "$APP" RAILS_ENV || echo 'production')
GIT_REV=$(dokku config:get "$APP" GIT_REV || printf '0%.0s' {1..41})
GIT_MESSAGE=$(git log "$GIT_REV" -n1 --pretty='format:%s' 2> /dev/null || echo '')
dokku_log_info1 "Notifying airbrake..."
curl "$BASE_URL/deploys.txt" --silent \
--data "api_key=$API_KEY" \
--data "deploy[local_username]=Dokku" \
--data "deploy[rails_env]=$RAILS_ENV" \
--data "deploy[scm_repository]=$REPO_URL" \
--data "deploy[scm_revision]=$GIT_REV" \
--data "deploy[message]=$GIT_MESSAGE" > /dev/null
exit 0
fi