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.
This commit is contained in:
21
.github/workflows/ci.yml
vendored
21
.github/workflows/ci.yml
vendored
@@ -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
|
||||
|
||||
18
.github/workflows/deploy.yml
vendored
18
.github/workflows/deploy.yml
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user