diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..4a51b0e --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,40 @@ +name: Deploy Express API + +on: + push: + branches: + - 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 & +