This commit is contained in:
@@ -10,40 +10,42 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Build API
|
|
||||||
run: |
|
|
||||||
cd api
|
|
||||||
npm ci
|
|
||||||
npx prisma generate
|
|
||||||
npm run build
|
|
||||||
|
|
||||||
- name: Build Web
|
- name: Build Web
|
||||||
run: |
|
run: |
|
||||||
cd web
|
cd web
|
||||||
npm ci
|
npm ci
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
- name: Deploy API
|
- name: Deploy with Docker Compose
|
||||||
run: |
|
run: |
|
||||||
pm2 stop skymoney-api || true
|
# Deploy directory
|
||||||
rm -rf /opt/skymoney/api/dist /opt/skymoney/api/node_modules
|
APP_DIR=/opt/skymoney
|
||||||
cp -r api/dist /opt/skymoney/api/
|
mkdir -p $APP_DIR
|
||||||
cp -r api/node_modules /opt/skymoney/api/
|
|
||||||
cp -r api/prisma /opt/skymoney/api/
|
|
||||||
|
|
||||||
# Run migrations using the VPS .env
|
# Sync repo to server (excluding node_modules, dist, etc)
|
||||||
cd /opt/skymoney/api
|
rsync -a --delete \
|
||||||
set -a
|
--exclude=node_modules \
|
||||||
source .env
|
--exclude=dist \
|
||||||
set +a
|
--exclude=.git \
|
||||||
npx prisma migrate deploy
|
--exclude=.gitea \
|
||||||
|
--exclude=backups \
|
||||||
|
--exclude=exporting \
|
||||||
|
./ $APP_DIR/
|
||||||
|
|
||||||
pm2 start /opt/skymoney/api/dist/server.js --name skymoney-api
|
# Copy built web to shared volume
|
||||||
|
mkdir -p /var/www/skymoney/dist
|
||||||
- name: Deploy Web
|
|
||||||
run: |
|
|
||||||
rm -rf /var/www/skymoney/dist/*
|
|
||||||
cp -r web/dist/* /var/www/skymoney/dist/
|
cp -r web/dist/* /var/www/skymoney/dist/
|
||||||
|
|
||||||
|
cd $APP_DIR
|
||||||
|
|
||||||
|
# Build and start all services
|
||||||
|
docker compose up -d --build
|
||||||
|
|
||||||
|
# Wait for database to be ready
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
# Run Prisma migrations inside the API container
|
||||||
|
docker compose exec -T api npx prisma migrate deploy
|
||||||
|
|
||||||
- name: Reload Nginx
|
- name: Reload Nginx
|
||||||
run: sudo systemctl reload nginx
|
run: sudo systemctl reload nginx
|
||||||
Reference in New Issue
Block a user