Fix deployment workflows and API crash loop #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Splitly Web to VPS | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| name: Deploy to Production Server | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to VPS via SSH | |
| uses: appleboy/ssh-action@v1.0.0 | |
| with: | |
| host: ${{ secrets.VPS_HOST }} | |
| username: ${{ secrets.VPS_USERNAME }} | |
| key: ${{ secrets.VPS_SSH_KEY }} | |
| port: 22 | |
| timeout: 300s | |
| script: | | |
| # Navigate to project directory | |
| cd ~/splitly | |
| # Pull latest changes | |
| git fetch origin | |
| git reset --hard origin/main | |
| # Build API | |
| cd ~/splitly/api | |
| npm install | |
| npm run build | |
| # Build Web | |
| cd ~/splitly/web | |
| npm install | |
| npm run build | |
| # Restart PM2 processes | |
| if pm2 describe splitly-api > /dev/null 2>&1; then | |
| pm2 restart splitly-api | |
| else | |
| cd ~/splitly/api | |
| BUILD_MODE=production pm2 start ./build/src/server.js --name splitly-api | |
| fi | |
| if pm2 describe splitly-web > /dev/null 2>&1; then | |
| pm2 restart splitly-web | |
| fi | |
| # Save PM2 config | |
| pm2 save | |
| # Show status | |
| pm2 status | |
| echo "✅ Deployment completed!" |