From 3ee72ec48a659859995e5e8da603cc2e9636321f Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 25 Jan 2026 15:35:56 +0300 Subject: [PATCH] chore: update CI and deployment workflows for improved notifications and permissions - Upgraded the upload-artifact action from v3 to v4 in CI workflow for better performance. - Added a notification step in the CI workflow to send test results via Telegram, including job status and repository details. - Modified the deployment workflow to ensure correct file permissions before and after code updates. - Renamed the deployment notification step for clarity and included a link to the action run details in the message. --- .github/workflows/ci.yml | 21 ++++++++++++++++++++- .github/workflows/deploy.yml | 18 +++++++++++++----- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95f1f03..6fa7afb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,10 +36,29 @@ jobs: - name: Upload test results if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: test-results path: | .pytest_cache/ htmlcov/ retention-days: 7 + + - name: Send test results notification + if: always() + uses: appleboy/telegram-action@v1.0.0 + with: + to: ${{ secrets.TELEGRAM_CHAT_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + message: | + 🧪 CI Tests ${{ job.status }} + + Repository: prod + Branch: ${{ github.ref_name }} + Commit: ${{ github.sha }} + Author: ${{ github.actor }} + + ${{ job.status == 'success' && '✅ All tests passed!' || '❌ Tests failed!' }} + + View details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + continue-on-error: true diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2ff8518..b11341e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,9 +1,7 @@ name: Deploy to Production on: - push: - branches: [ main ] - workflow_dispatch: # Позволяет запускать вручную + workflow_dispatch: # Только ручной запуск jobs: deploy: @@ -34,9 +32,16 @@ jobs: # Обновляем код echo "📥 Pulling latest changes..." + + # Исправляем права на файлы перед обновлением + sudo chown -R deploy:deploy /home/prod || true + git fetch origin main git reset --hard origin/main + # Устанавливаем правильные права после обновления + sudo chown -R deploy:deploy /home/prod || true + # Проверяем, что изменения есть NEW_COMMIT=$(git rev-parse HEAD) if [ "$CURRENT_COMMIT" = "$NEW_COMMIT" ]; then @@ -50,6 +55,7 @@ jobs: if command -v make &> /dev/null; then make restart || docker-compose restart else + cd /home/prod docker-compose down docker-compose up -d --build fi @@ -90,7 +96,7 @@ jobs: echo "✅ All health checks passed" - - name: Send notification (optional) + - name: Send deployment notification if: always() uses: appleboy/telegram-action@v1.0.0 with: @@ -105,4 +111,6 @@ jobs: Author: ${{ github.actor }} ${{ job.status == 'success' && '✅ Deployment successful!' || '❌ Deployment failed!' }} - continue-on-error: true # Не падаем, если уведомление не отправилось + + View details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + continue-on-error: true