From 2ee6ea2b3832382909024ffdc01b35e2c08db26f Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 1 Mar 2026 00:20:36 +0300 Subject: [PATCH] fix ci & deploy --- .github/workflows/ci.yml | 6 +++--- .github/workflows/deploy.yml | 32 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 795ec38..fdf64bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ on: push: branches: [ 'dev-*', 'feature-*', 'fix-*' ] pull_request: - branches: [ 'dev-*', 'feature-*', 'fix-*', 'main' ] + branches: [ 'dev-*', 'feature-*', 'fix-*', 'master' ] workflow_dispatch: jobs: @@ -72,7 +72,7 @@ jobs: ✅ All tests passed! Code quality checks completed successfully. - 🔗 View details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + 🔗 View details: ${{ vars.GITEA_PUBLIC_URL || github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} continue-on-error: true - name: Send test failure notification @@ -91,5 +91,5 @@ jobs: ❌ Tests failed! Deployment blocked. Please fix the issues and try again. - 🔗 View details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + 🔗 View details: ${{ vars.GITEA_PUBLIC_URL || github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} continue-on-error: true \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7ef4561..1e57e16 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,7 +2,7 @@ name: Deploy to Production on: push: - branches: [ main ] + branches: [ master ] workflow_dispatch: inputs: action: @@ -44,7 +44,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - ref: main + ref: master - name: Dry run (simulate deploy steps) if: github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'yes' @@ -53,7 +53,7 @@ jobs: echo "Would run on server:" echo " 1. cd /home/prod/bots/telegram-helper-bot" echo " 2. CURRENT_COMMIT=\$(git rev-parse HEAD); write to .deploy_history_telegram_helper_bot.txt" - echo " 3. git fetch origin main && git reset --hard origin/main" + echo " 3. git fetch origin master && git reset --hard origin/master" echo " 4. python3 scripts/apply_migrations.py --db ... (if DB exists)" echo " 5. docker-compose -f /home/prod/docker-compose.yml config (validate)" echo " 6. docker-compose stop telegram-bot; build --pull telegram-bot; up -d telegram-bot" @@ -99,9 +99,9 @@ jobs: tail -n "$HISTORY_SIZE" "$HISTORY_FILE" > "${HISTORY_FILE}.tmp" && mv "${HISTORY_FILE}.tmp" "$HISTORY_FILE" # Обновляем код - echo "📥 Pulling latest changes from main..." - git fetch origin main - git reset --hard origin/main + echo "📥 Pulling latest changes from master..." + git fetch origin master + git reset --hard origin/master sudo chown -R deploy:deploy /home/prod/bots/telegram-helper-bot || true NEW_COMMIT=$(git rev-parse HEAD) @@ -192,13 +192,13 @@ jobs: ${{ job.status == 'success' && '✅' || '❌' }} Deployment: ${{ job.status }} 📦 Repository: telegram-helper-bot - 🌿 Branch: main + 🌿 Branch: master 📝 Commit: ${{ github.sha }} 👤 Author: ${{ github.actor }} ${{ job.status == 'success' && '✅ Deployment successful! Container restarted with migrations applied.' || '❌ Deployment failed! Check logs for details.' }} - 🔗 View details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + 🔗 View details: ${{ vars.GITEA_PUBLIC_URL || github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} continue-on-error: true - name: Get PR body from merged PR @@ -208,14 +208,14 @@ jobs: run: | echo "🔍 Searching for merged PR associated with commit ${{ github.sha }}..." - # Находим последний мерженный PR для main ветки по merge commit SHA + # Находим последний мерженный PR для master по merge commit SHA COMMIT_SHA="${{ github.sha }}" - PR_NUMBER=$(gh pr list --state merged --base main --limit 10 --json number,mergeCommit --jq ".[] | select(.mergeCommit.oid == \"$COMMIT_SHA\") | .number" | head -1) + PR_NUMBER=$(gh pr list --state merged --base master --limit 10 --json number,mergeCommit --jq ".[] | select(.mergeCommit.oid == \"$COMMIT_SHA\") | .number" | head -1) # Если не нашли по merge commit, ищем последний мерженный PR if [ -z "$PR_NUMBER" ]; then echo "⚠️ PR not found by merge commit, trying to get latest merged PR..." - PR_NUMBER=$(gh pr list --state merged --base main --limit 1 --json number --jq '.[0].number') + PR_NUMBER=$(gh pr list --state merged --base master --limit 1 --json number --jq '.[0].number') fi if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then @@ -247,7 +247,7 @@ jobs: ${{ env.PR_BODY }} - 🔗 PR: ${{ github.server_url }}/${{ github.repository }}/pull/${{ env.PR_NUMBER }} + 🔗 PR: ${{ vars.GITEA_PUBLIC_URL || github.server_url }}/${{ github.repository }}/pull/${{ env.PR_NUMBER }} 📝 Commit: ${{ github.sha }} continue-on-error: true @@ -264,7 +264,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - ref: main + ref: master - name: Rollback on server uses: appleboy/ssh-action@v1.0.0 @@ -322,7 +322,7 @@ jobs: # Откатываем код echo "🔄 Rolling back code..." - git fetch origin main + git fetch origin master git reset --hard "$ROLLBACK_COMMIT" # Исправляем права после отката @@ -374,12 +374,12 @@ jobs: ${{ job.status == 'success' && '🔄' || '❌' }} Rollback: ${{ job.status }} 📦 Repository: telegram-helper-bot - 🌿 Branch: main + 🌿 Branch: master 📝 Rolled back to: ${{ github.event.inputs.rollback_commit || 'Last successful commit' }} 👤 Triggered by: ${{ github.actor }} ${{ job.status == 'success' && '✅ Rollback completed successfully! Services restored to previous version.' || '❌ Rollback failed! Check logs for details.' }} - 🔗 View details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + 🔗 View details: ${{ vars.GITEA_PUBLIC_URL || github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} continue-on-error: true