This commit is contained in:
sHa
2019-09-26 10:49:04 +03:00
parent 0af62bd778
commit 799d9e8b07
6 changed files with 34 additions and 49 deletions

32
scripts/slack/post_merge Normal file
View File

@@ -0,0 +1,32 @@
#!/bin/sh
#
# @category Boxes
# @package git scripts
# @author sHa <sha@shadoll.dev>
# @copyright 2019 Fabrika-Klientov
# @version 19.9.26
# @link https://fabrika-klientov.ua
DIR=`dirname "$(readlink -f "$0")"`
DIR=${DIR%/*}
if [ "${DIR##*/}" = ".git" ]; then
DIR=${DIR%/*}
fi
HOST=`hostname`
USER=`whoami`
REPO=$(basename -s .git `git config --get remote.origin.url`)
BRANCH=`git branch | grep \* | cut -d ' ' -f2`
[ -f $DIR/.env ] && CHANNEL=$(grep -e '^SLACK_CHANNEL=.*' $DIR/.env | cut -d '=' -f2)
[ -z "$CHANNEL" ] && CHANNEL="general"
[ -f $DIR/.env ] && TOKEN=$(grep -e '^SLACK_TOKEN=.*' $DIR/.env | cut -d '=' -f2)
#[ -z "$TOKEN" ] && TOKEN=""
[ -f $DIR/.env ] && APP=$(grep -e '^APP_NAME=.*' $DIR/.env | cut -d '=' -f2)
[ -z "$APP" ] && APP="App"
if [ "$TOKEN" ]; then
curl -X GET --get --data-urlencode "text=*$APP⎇$BRANCH* merged on $USER@$HOST" 'https://slack.com/api/chat.postMessage?token='$TOKEN'&channel='$CHANNEL
fi