From 5a0c2d6942c20e3b3b931cde1a51889dd0194296 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 25 Jan 2026 15:46:58 +0300 Subject: [PATCH] chore: remove CI and deployment workflows to streamline processes - Deleted outdated CI workflow file to simplify the continuous integration process. - Removed deployment workflow file to eliminate redundancy and focus on a more efficient deployment strategy. --- .github/workflows/ci.yml | 66 -------------- .github/workflows/deploy.yml | 160 --------------------------------- .github/workflows/pipeline.yml | 4 +- 3 files changed, 1 insertion(+), 229 deletions(-) delete mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 4fcae85..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: CI - Infrastructure Tests - -on: - push: - branches: [ main, develop, 'feature/**' ] - pull_request: - branches: [ main, develop ] - -jobs: - test: - runs-on: ubuntu-latest - name: Run Infrastructure Tests - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: '3.11' - cache: 'pip' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r tests/infra/requirements-test.txt - - - name: Run infrastructure tests - run: | - python -m pytest tests/infra/ -v --tb=short - - - name: Validate Prometheus config - run: | - python -m pytest tests/infra/test_prometheus_config.py -v - - - name: Upload test results - if: always() - 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! Ready for deployment.' || '❌ Tests failed! Deployment blocked.' }} - - ${{ job.status == 'success' && format('🚀 You can now deploy manually: {0}/{1}/actions/workflows/deploy.yml', github.server_url, github.repository) || '' }} - - 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 deleted file mode 100644 index acc1b23..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,160 +0,0 @@ -name: Deploy to Production - -on: - workflow_dispatch: # Только ручной запуск - -jobs: - check-ci-status: - runs-on: ubuntu-latest - name: Check CI Status - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Check last CI run status - uses: actions/github-script@v7 - with: - script: | - const { data: runs } = await github.rest.actions.listWorkflowRuns({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: 'ci.yml', - branch: 'main', - per_page: 1 - }); - - if (runs.workflow_runs.length === 0) { - core.setFailed('❌ No CI runs found. Please run CI first.'); - return; - } - - const lastRun = runs.workflow_runs[0]; - const status = lastRun.status; - const conclusion = lastRun.conclusion; - - console.log(`Last CI run: ${lastRun.id}`); - console.log(`Status: ${status}, Conclusion: ${conclusion}`); - - if (status !== 'completed') { - core.setFailed(`❌ Last CI run is still ${status}. Please wait for it to complete.`); - return; - } - - if (conclusion !== 'success') { - core.setFailed(`❌ Last CI run failed (${conclusion}). Please fix tests before deploying.`); - return; - } - - console.log('✅ Last CI run passed successfully. Ready for deployment!'); - - deploy: - runs-on: ubuntu-latest - name: Deploy Infrastructure - needs: check-ci-status - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Deploy to server - uses: appleboy/ssh-action@v1.0.0 - with: - host: ${{ vars.SERVER_HOST || secrets.SERVER_HOST }} - username: ${{ vars.SERVER_USER || secrets.SERVER_USER }} - key: ${{ secrets.SSH_PRIVATE_KEY }} - port: ${{ vars.SSH_PORT || secrets.SSH_PORT || 22 }} - script: | - set -e - echo "🚀 Starting deployment..." - - # Переходим в директорию проекта - cd /home/prod - - # Сохраняем текущий коммит для отката - CURRENT_COMMIT=$(git rev-parse HEAD) - echo "Current commit: $CURRENT_COMMIT" > /tmp/last_deploy_commit.txt - - # Обновляем код - 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 - echo "ℹ️ No new changes to deploy" - else - echo "✅ Code updated: $CURRENT_COMMIT → $NEW_COMMIT" - fi - - # Перезапускаем сервисы - echo "🔄 Restarting services..." - 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 - - echo "✅ Deployment completed" - - - name: Health check - uses: appleboy/ssh-action@v1.0.0 - with: - host: ${{ vars.SERVER_HOST || secrets.SERVER_HOST }} - username: ${{ vars.SERVER_USER || secrets.SERVER_USER }} - key: ${{ secrets.SSH_PRIVATE_KEY }} - port: ${{ vars.SSH_PORT || secrets.SSH_PORT || 22 }} - script: | - echo "🏥 Running health checks..." - sleep 15 # Даем время сервисам запуститься - - # Проверяем Prometheus - if curl -f http://localhost:9090/-/healthy > /dev/null 2>&1; then - echo "✅ Prometheus is healthy" - else - echo "❌ Prometheus health check failed" - exit 1 - fi - - # Проверяем Grafana - if curl -f http://localhost:3000/api/health > /dev/null 2>&1; then - echo "✅ Grafana is healthy" - else - echo "❌ Grafana health check failed" - exit 1 - fi - - # Проверяем статус контейнеров - echo "📊 Container status:" - cd /home/prod - docker-compose ps || docker ps --filter "name=bots_" - - echo "✅ All health checks passed" - - - name: Send deployment notification - if: always() - uses: appleboy/telegram-action@v1.0.0 - with: - to: ${{ secrets.TELEGRAM_CHAT_ID }} - token: ${{ secrets.TELEGRAM_BOT_TOKEN }} - message: | - 🚀 Deployment ${{ job.status }} - - Repository: prod - Branch: ${{ github.ref_name }} - Commit: ${{ github.sha }} - Author: ${{ github.actor }} - - ${{ job.status == 'success' && '✅ Deployment successful!' || '❌ Deployment failed!' }} - - View details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - continue-on-error: true diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 32c1387..2448c17 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -10,8 +10,6 @@ jobs: test: runs-on: ubuntu-latest name: Test - outputs: - status: ${{ job.status }} steps: - name: Checkout code @@ -69,7 +67,7 @@ jobs: runs-on: ubuntu-latest name: Deploy needs: test - if: needs.test.outputs.status == 'success' && (github.ref == 'refs/heads/main' || github.event_name == 'pull_request') + if: success() && github.ref == 'refs/heads/main' environment: name: production url: https://${{ vars.SERVER_HOST || secrets.SERVER_HOST }}