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
|
- name: Upload test results
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: test-results
|
name: test-results
|
||||||
path: |
|
path: |
|
||||||
.pytest_cache/
|
.pytest_cache/
|
||||||
htmlcov/
|
htmlcov/
|
||||||
retention-days: 7
|
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
|
name: Deploy to Production
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_dispatch: # Только ручной запуск
|
||||||
branches: [ main ]
|
|
||||||
workflow_dispatch: # Позволяет запускать вручную
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
@@ -34,9 +32,16 @@ jobs:
|
|||||||
|
|
||||||
# Обновляем код
|
# Обновляем код
|
||||||
echo "📥 Pulling latest changes..."
|
echo "📥 Pulling latest changes..."
|
||||||
|
|
||||||
|
# Исправляем права на файлы перед обновлением
|
||||||
|
sudo chown -R deploy:deploy /home/prod || true
|
||||||
|
|
||||||
git fetch origin main
|
git fetch origin main
|
||||||
git reset --hard origin/main
|
git reset --hard origin/main
|
||||||
|
|
||||||
|
# Устанавливаем правильные права после обновления
|
||||||
|
sudo chown -R deploy:deploy /home/prod || true
|
||||||
|
|
||||||
# Проверяем, что изменения есть
|
# Проверяем, что изменения есть
|
||||||
NEW_COMMIT=$(git rev-parse HEAD)
|
NEW_COMMIT=$(git rev-parse HEAD)
|
||||||
if [ "$CURRENT_COMMIT" = "$NEW_COMMIT" ]; then
|
if [ "$CURRENT_COMMIT" = "$NEW_COMMIT" ]; then
|
||||||
@@ -50,6 +55,7 @@ jobs:
|
|||||||
if command -v make &> /dev/null; then
|
if command -v make &> /dev/null; then
|
||||||
make restart || docker-compose restart
|
make restart || docker-compose restart
|
||||||
else
|
else
|
||||||
|
cd /home/prod
|
||||||
docker-compose down
|
docker-compose down
|
||||||
docker-compose up -d --build
|
docker-compose up -d --build
|
||||||
fi
|
fi
|
||||||
@@ -90,7 +96,7 @@ jobs:
|
|||||||
|
|
||||||
echo "✅ All health checks passed"
|
echo "✅ All health checks passed"
|
||||||
|
|
||||||
- name: Send notification (optional)
|
- name: Send deployment notification
|
||||||
if: always()
|
if: always()
|
||||||
uses: appleboy/telegram-action@v1.0.0
|
uses: appleboy/telegram-action@v1.0.0
|
||||||
with:
|
with:
|
||||||
@@ -105,4 +111,6 @@ jobs:
|
|||||||
Author: ${{ github.actor }}
|
Author: ${{ github.actor }}
|
||||||
|
|
||||||
${{ job.status == 'success' && '✅ Deployment successful!' || '❌ Deployment failed!' }}
|
${{ 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