Files
hotelsync/.gitea/workflows/deploy.yml
2026-03-28 16:46:24 +03:00

84 lines
2.7 KiB
YAML

name: Deploy to Production
on:
push:
branches:
- main
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Pull latest code
run: |
cd /opt/hotelsync/app
git fetch http://golomazov:Jbs5%40TikW@localhost:3001/golomazov/hotelsync.git main
git reset --hard FETCH_HEAD
echo "✅ Code updated"
- name: Copy env
run: cp /opt/hotelsync/.env /opt/hotelsync/app/.env
- name: Build Docker images
run: |
cd /opt/hotelsync/app
docker build -t hotelsync-frontend:latest .
docker build -t hotelsync-cp:latest ./cp
docker build -t hotelsync-api:latest ./backend
echo "✅ Images built"
- name: Restart API container
run: |
mkdir -p /opt/hotelsync/uploads /opt/hotelsync/agent-updates
docker stop hotelsync-api 2>/dev/null || true
docker rm hotelsync-api 2>/dev/null || true
docker run -d \
--name hotelsync-api \
--network hotelsync_hotelsync-net \
--network-alias api \
--restart unless-stopped \
--env-file /opt/hotelsync/.env \
-v /opt/hotelsync/uploads:/app/uploads \
-v /opt/hotelsync/agent-updates:/app/agent-updates:ro \
-e UPLOADS_DIR=/app/uploads \
-e CDN_HOST=api.hotelsync.ru/uploads \
-e AGENT_UPDATES_DIR=/app/agent-updates \
hotelsync-api:latest
echo "✅ API started"
- name: Restart frontend container
run: |
docker stop hotelsync-frontend 2>/dev/null || true
docker rm hotelsync-frontend 2>/dev/null || true
docker run -d \
--name hotelsync-frontend \
--network hotelsync_hotelsync-net \
--network-alias frontend \
--restart unless-stopped \
hotelsync-frontend:latest
echo "✅ Frontend started"
- name: Restart CP container
run: |
docker stop hotelsync-cp 2>/dev/null || true
docker rm hotelsync-cp 2>/dev/null || true
docker run -d \
--name hotelsync-cp \
--network hotelsync_hotelsync-net \
--network-alias cp \
--restart unless-stopped \
hotelsync-cp:latest
echo "✅ CP started"
- name: Sync nginx config
run: cp /opt/hotelsync/app/nginx/conf.d/hotelsync.conf /opt/hotelsync/nginx/conf.d/hotelsync.conf
- name: Reload nginx
run: docker exec hotelsync-nginx nginx -s reload
- name: Health check
run: |
sleep 3
curl -sf http://localhost/ > /dev/null && echo "✅ App is alive!" || echo "⚠️ Check app manually"