fix ci & deploy
Some checks failed
CI pipeline / Test & Code Quality (pull_request) Has been cancelled
CI pipeline / Test & Code Quality (push) Successful in 34s

This commit is contained in:
2026-03-01 00:20:36 +03:00
parent 118189da82
commit 2ee6ea2b38
2 changed files with 19 additions and 19 deletions

View File

@@ -4,7 +4,7 @@ on:
push: push:
branches: [ 'dev-*', 'feature-*', 'fix-*' ] branches: [ 'dev-*', 'feature-*', 'fix-*' ]
pull_request: pull_request:
branches: [ 'dev-*', 'feature-*', 'fix-*', 'main' ] branches: [ 'dev-*', 'feature-*', 'fix-*', 'master' ]
workflow_dispatch: workflow_dispatch:
jobs: jobs:
@@ -72,7 +72,7 @@ jobs:
✅ All tests passed! Code quality checks completed successfully. ✅ 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 continue-on-error: true
- name: Send test failure notification - name: Send test failure notification
@@ -91,5 +91,5 @@ jobs:
❌ Tests failed! Deployment blocked. Please fix the issues and try again. ❌ 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 continue-on-error: true

View File

@@ -2,7 +2,7 @@ name: Deploy to Production
on: on:
push: push:
branches: [ main ] branches: [ master ]
workflow_dispatch: workflow_dispatch:
inputs: inputs:
action: action:
@@ -44,7 +44,7 @@ jobs:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: main ref: master
- name: Dry run (simulate deploy steps) - name: Dry run (simulate deploy steps)
if: github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'yes' if: github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'yes'
@@ -53,7 +53,7 @@ jobs:
echo "Would run on server:" echo "Would run on server:"
echo " 1. cd /home/prod/bots/telegram-helper-bot" 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 " 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 " 4. python3 scripts/apply_migrations.py --db ... (if DB exists)"
echo " 5. docker-compose -f /home/prod/docker-compose.yml config (validate)" 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" 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" tail -n "$HISTORY_SIZE" "$HISTORY_FILE" > "${HISTORY_FILE}.tmp" && mv "${HISTORY_FILE}.tmp" "$HISTORY_FILE"
# Обновляем код # Обновляем код
echo "📥 Pulling latest changes from main..." echo "📥 Pulling latest changes from master..."
git fetch origin main git fetch origin master
git reset --hard origin/main git reset --hard origin/master
sudo chown -R deploy:deploy /home/prod/bots/telegram-helper-bot || true sudo chown -R deploy:deploy /home/prod/bots/telegram-helper-bot || true
NEW_COMMIT=$(git rev-parse HEAD) NEW_COMMIT=$(git rev-parse HEAD)
@@ -192,13 +192,13 @@ jobs:
${{ job.status == 'success' && '✅' || '❌' }} Deployment: ${{ job.status }} ${{ job.status == 'success' && '✅' || '❌' }} Deployment: ${{ job.status }}
📦 Repository: telegram-helper-bot 📦 Repository: telegram-helper-bot
🌿 Branch: main 🌿 Branch: master
📝 Commit: ${{ github.sha }} 📝 Commit: ${{ github.sha }}
👤 Author: ${{ github.actor }} 👤 Author: ${{ github.actor }}
${{ job.status == 'success' && '✅ Deployment successful! Container restarted with migrations applied.' || '❌ Deployment failed! Check logs for details.' }} ${{ 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 continue-on-error: true
- name: Get PR body from merged PR - name: Get PR body from merged PR
@@ -208,14 +208,14 @@ jobs:
run: | run: |
echo "🔍 Searching for merged PR associated with commit ${{ github.sha }}..." echo "🔍 Searching for merged PR associated with commit ${{ github.sha }}..."
# Находим последний мерженный PR для main ветки по merge commit SHA # Находим последний мерженный PR для master по merge commit SHA
COMMIT_SHA="${{ github.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 # Если не нашли по merge commit, ищем последний мерженный PR
if [ -z "$PR_NUMBER" ]; then if [ -z "$PR_NUMBER" ]; then
echo "⚠️ PR not found by merge commit, trying to get latest merged PR..." 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 fi
if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then
@@ -247,7 +247,7 @@ jobs:
${{ env.PR_BODY }} ${{ 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 }} 📝 Commit: ${{ github.sha }}
continue-on-error: true continue-on-error: true
@@ -264,7 +264,7 @@ jobs:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: main ref: master
- name: Rollback on server - name: Rollback on server
uses: appleboy/ssh-action@v1.0.0 uses: appleboy/ssh-action@v1.0.0
@@ -322,7 +322,7 @@ jobs:
# Откатываем код # Откатываем код
echo "🔄 Rolling back code..." echo "🔄 Rolling back code..."
git fetch origin main git fetch origin master
git reset --hard "$ROLLBACK_COMMIT" git reset --hard "$ROLLBACK_COMMIT"
# Исправляем права после отката # Исправляем права после отката
@@ -374,12 +374,12 @@ jobs:
${{ job.status == 'success' && '🔄' || '❌' }} Rollback: ${{ job.status }} ${{ job.status == 'success' && '🔄' || '❌' }} Rollback: ${{ job.status }}
📦 Repository: telegram-helper-bot 📦 Repository: telegram-helper-bot
🌿 Branch: main 🌿 Branch: master
📝 Rolled back to: ${{ github.event.inputs.rollback_commit || 'Last successful commit' }} 📝 Rolled back to: ${{ github.event.inputs.rollback_commit || 'Last successful commit' }}
👤 Triggered by: ${{ github.actor }} 👤 Triggered by: ${{ github.actor }}
${{ job.status == 'success' && '✅ Rollback completed successfully! Services restored to previous version.' || '❌ Rollback failed! Check logs for details.' }} ${{ 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 continue-on-error: true