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