51 lines
1.2 KiB
YAML
51 lines
1.2 KiB
YAML
name: Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: vps-host
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Build Web
|
|
run: |
|
|
cd web
|
|
npm ci
|
|
npm run build
|
|
|
|
- name: Deploy with Docker Compose
|
|
run: |
|
|
# Deploy directory
|
|
APP_DIR=/opt/skymoney
|
|
mkdir -p $APP_DIR
|
|
|
|
# Sync repo to server (excluding node_modules, dist, etc)
|
|
rsync -a --delete \
|
|
--exclude=node_modules \
|
|
--exclude=dist \
|
|
--exclude=.git \
|
|
--exclude=.gitea \
|
|
--exclude=backups \
|
|
--exclude=exporting \
|
|
./ $APP_DIR/
|
|
|
|
# Copy built web to shared volume
|
|
mkdir -p /var/www/skymoney/dist
|
|
cp -r web/dist/* /var/www/skymoney/dist/
|
|
|
|
cd $APP_DIR
|
|
|
|
# Build and start all services
|
|
sudo docker-compose up -d --build
|
|
|
|
# Wait for database to be ready
|
|
sleep 10
|
|
|
|
# Run Prisma migrations inside the API container
|
|
sudo docker-compose exec -T api npx prisma migrate deploy
|
|
|
|
- name: Reload Nginx
|
|
run: sudo systemctl reload nginx |