deploy-workflow: create docker compose file
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 7s

This commit is contained in:
2026-07-04 17:08:41 +03:00
parent 8700d316fa
commit feaf427969
2 changed files with 15 additions and 16 deletions
+15 -16
View File
@@ -83,44 +83,43 @@ jobs:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_DEPLOY_BOT_TOKEN }}
TELEGRAM_CHAT: ${{ secrets.TELEGRAM_DEPLOY_CHAT_ID }}
PROXY_URL: ${{ secrets.PROXY_URL }}
SUCCESS_MSG: |-
✅ <b>Деплой успешен!</b>
Сервер применил релиз: <code>${{ env.CLEAN_REF_NAME }}</code>
FAILURE_MSG: |-
SUCCESS_MESSAGE: |-
✅ <b>Успешный делой!</b>
Релиз: <code>${{ gitea.ref_name }}</code>
FAILURE_MESSAGE: |-
❌ <b>Ошибка деплоя!</b>
Сервер <b>не</b> применил релиз: <code>${{ env.CLEAN_REF_NAME }}</code>
Релиз: <code>${{ gitea.ref_name }}</code>
run: |
sshpass -e ssh -p 22 "$SSH_USERNAME@$SSH_HOST" bash -s << EOT
set -e
cd "$DEPLOY_DIRECTORY"
nohup bash -c '
sleep 10
DEPLOY_LOG_FILE="/tmp/deploy-${REF_NAME}.log"
if docker compose --dry-run -f "docker-compose-${REF_NAME}.yml" up -d --remove-orphans > /tmp/docker_deploy.log 2>&1; then
nohup bash -c '
sleep 5
if docker compose --dry-run -f "docker-compose-${REF_NAME}.yml" up -d --remove-orphans > \${DEPLOY_LOG_FILE} 2>&1; then
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage" \
--proxy "${PROXY_URL}" \
-d "chat_id=${TELEGRAM_CHAT}" \
-d "parse_mode=HTML" \
--data-urlencode "text=${SUCCESS_MSG}" > /dev/null
--data-urlencode "text=${SUCCESS_MESSAGE}" > /dev/null
else
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage" \
--proxy "${PROXY_URL}" \
-d "chat_id=${TELEGRAM_CHAT}" \
-d "parse_mode=HTML" \
--data-urlencode "text=${FAILURE_MSG}" > /dev/null
--data-urlencode "text=${FAILURE_MESSAGE}" > /dev/null
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument" \
--proxy "${PROXY_URL}" \
-F "chat_id=${TELEGRAM_CHAT}" \
-F "document=@/tmp/docker_deploy.log" \
-F "caption=logs" > /dev/null
-F "document=@\${DEPLOY_LOG_FILE}" > /dev/null
fi
rm -f /tmp/docker_deploy.log
rm -f \${DEPLOY_LOG_FILE}
' > /dev/null 2>&1 &
EOT
echo "New containers will be started after 10 seconds"
echo "New containers will be started after 5 seconds"