cicd-scripts/honestyui-build.sh

34 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
source .env
GIT_PATH=$HONESTY_UI_GIT_PATH
DOCKER_BUILD_PATH=$HONESTY_UI_DOCKER_BUILD_PATH
DOCKER_RUN_PATH=$HONESTY_UI_DOCKER_RUN_PATH
TG_CHATID=$HONESTY_TG_CHATID
echo "Content-type: text/plain"
echo ""
COMMIT_ID=$(git -C $GIT_PATH log -n 1 --abbrev=7 --pretty=format:"%h")
COMMIT_MSG=$(git -C $GIT_PATH log -1 --pretty=format:"%s%n%b")
COMMIT_BY=$(git -C $GIT_PATH log -1 --pretty=format:%an)
TGTEXT=$(echo Deployment Triggered %0A $(date "+%H:%M:%S %a %b %d %Y") %0A%0A Current Commit by: $COMMIT_BY %0A ID: $COMMIT_ID %0A Message: $COMMIT_MSG | sed "s/ /%20/g")
curl -s $TG_BOTAPI$TG_BOT_TOKEN/sendMessage?chat_id=$HONESTY_TG_CHATID'&'text=$TGTEXT
git -C $GIT_PATH pull
docker compose -f $DOCKER_BUILD_PATH/docker-compose.yml build
docker compose -f $DOCKER_BUILD_PATH/docker-compose.yml push
docker compose -f $DOCKER_RUN_PATH/docker-compose.yml pull
docker compose -f $DOCKER_RUN_PATH/docker-compose.yml down
docker compose -f $DOCKER_RUN_PATH/docker-compose.yml up -d
COMMIT_ID=$(git -C $GIT_PATH log -n 1 --abbrev=7 --pretty=format:"%h")
COMMIT_MSG=$(git -C $GIT_PATH log -1 --pretty=format:"%s%n%b")
COMMIT_BY=$(git -C $GIT_PATH log -1 --pretty=format:%an)
TGTEXT=$(echo Deployment Completed %0A $(date "+%H:%M:%S %a %b %d %Y") %0A%0A New Commit by: $COMMIT_BY %0A ID: $COMMIT_ID %0A Message: $COMMIT_MSG | sed "s/ /%20/g")
curl -s $TG_BOTAPI$TG_BOT_TOKEN/sendMessage?chat_id=$TG_CHATID'&'text=$TGTEXT
echo ""
echo "prolly done, check for yourself"