name: Deploy Express API on: push: branches: - backend - main jobs: deploy: runs-on: linux_amd64 steps: # Checkout code - uses: actions/checkout@v3 # Pull latest code - name: Pull latest code run: | cd /var/www/myapp/Project git reset --hard git pull origin main # Install dependencies - name: Install dependencies run: | cd /var/www/myapp/Project npm install # Kill existing process (optional) - name: Stop previous instance run: | pkill -f "node .*app.js" || true pkill -f "node .*start.js" || true # Start app in background - name: Start app run: | cd /var/www/myapp/Project nohup npm start > app.log 2>&1 &