diff --git a/.github/workflows/depoly.yml b/.github/workflows/depoly.yml new file mode 100644 index 0000000..4fe51e4 --- /dev/null +++ b/.github/workflows/depoly.yml @@ -0,0 +1,29 @@ +name: Deploy Backend to VPS + +# Run on push to the main branch +on: + push: + branches: + - ${{ secrets.SERVER_BRANCH }} + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: SSH into server and deploy backend + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.SERVER_HOST }} + username: ${{ secrets.SERVER_USER }} + key: ${{ secrets.SERVER_SSH_KEY }} + script: | + echo "--- Starting Backend Deployment ---" + cd /var/www/backend + echo "Pulling backend changes..." + git pull origin ${{ secrets.SERVER_BRANCH }} + echo "Installing backend dependencies..." + npm install + echo "Restarting backend app..." + pm2 restart backend-app + echo "--- Backend Deployment Complete ---"