Primakov Alexandr Alexandrovich 493a14e2c8 Enhance deployment documentation and add redeploy guide
- Updated `README.md` to include instructions for the new `redeploy-ubuntu.sh` script and added a link to the new `REDEPLOY_GUIDE.md`.
- Created `REDEPLOY_GUIDE.md` detailing the redeployment process, including backup creation, code updates, and troubleshooting steps.
- Introduced `redeploy-hint.md` for GitHub Actions automation example, outlining setup for automatic redeployment on push events.
- Improved documentation structure for better navigation and clarity.
2025-10-13 00:15:47 +03:00

84 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 🔄 Автоматический Redeploy через GitHub Actions (пример)
Этот файл показывает, как настроить автоматическое обновление сервера при push в main.
## ⚠️ Важно
Этот workflow **НЕ** включен по умолчанию для безопасности. Чтобы включить:
1. Переименуйте этот файл: `redeploy-hint.md``redeploy.yml`
2. Настройте secrets в GitHub:
- `SSH_PRIVATE_KEY` - SSH ключ для доступа к серверу
- `SERVER_HOST` - IP адрес или домен сервера
- `SERVER_USER` - Пользователь на сервере
## Пример workflow:
```yaml
name: Redeploy to Production
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /opt/ai-review
sudo git pull origin main
sudo ./redeploy-ubuntu.sh
- name: Check service status
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
sudo systemctl status ai-review --no-pager
- name: Notify on failure
if: failure()
run: echo "Deployment failed! Check the logs."
```
## Альтернатива: Webhook
Можно настроить webhook, который будет вызывать redeploy при push:
```bash
# На сервере создать endpoint для webhook
# /opt/ai-review/webhook-server.sh
#!/bin/bash
# Простой webhook сервер
while true; do
echo -e "HTTP/1.1 200 OK\n\n$(sudo /opt/ai-review/redeploy-ubuntu.sh 2>&1)" | nc -l -p 9000
done
```
Затем в GitHub:
1. Settings → Webhooks → Add webhook
2. Payload URL: `http://your-server:9000`
3. Content type: `application/json`
4. Events: `Just the push event`
## Безопасность
⚠️ **Не используйте автоматический деплой без:**
1. Тестов в CI/CD
2. Staging окружения
3. Возможности быстрого отката
4. Мониторинга после деплоя