name: Deploy Node App
on:
  push:
    branches:
      - main
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v3

      
      - name: Copy files to VPS
        uses: appleboy/scp-action@master
        with:
          host: 172.236.185.26
          username: root
          password: LinodeUser#26
          port: 22
          source: "./*"
          target: "/root/gyanBuddy"

      
      - name: Execute SSH Commands
        uses: appleboy/ssh-action@master
        with:
          host: 172.236.185.26
          username: root
          password: LinodeUser#26
          port: 22
          script: |
            cd /root/gyanBuddy
            npm install
            pm2 restart gyanBuddy
