-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpost-deploy
executable file
·21 lines (18 loc) · 934 Bytes
/
post-deploy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"
HOSTNAME=$(hostname -f)
TELEGRAM_API="https://api.telegram.org/bot"
TELEGRAM_ENDPOINT="/sendMessage"
echo "Trying to find token and chat_id for ${APP}"
if [[ -f "$DOKKU_ROOT/$APP/TELEGRAM_TOKEN" || -f "$DOKKU_ROOT/TELEGRAM_TOKEN" ]]; then
if [[ -f "$DOKKU_ROOT/$APP/TELEGRAM_CHAT_ID" || -f "$DOKKU_ROOT/TELEGRAM_CHAT_ID" ]]; then
echo "-----> Notifying Telegram chat ..."
URL=$(dokku urls $APP|tail -n1)
TOKEN=$(cat "$DOKKU_ROOT/$APP/TELEGRAM_TOKEN" 2> /dev/null || cat "$DOKKU_ROOT/TELEGRAM_TOKEN" 2> /dev/null)
CHAT_ID=$(cat "$DOKKU_ROOT/$APP/TELEGRAM_CHAT_ID" 2> /dev/null || cat "$DOKKU_ROOT/TELEGRAM_CHAT_ID" 2> /dev/null)
TEXT="Deployed $APP to $HOSTNAME via $URL"
RESULT=$(curl -X POST "${TELEGRAM_API}${TOKEN}${TELEGRAM_ENDPOINT}" -w "%{http_code}" -F chat_id="${CHAT_ID}" -F text="${TEXT}")
echo "${RESULT}"
fi
fi