name: Deploy
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: self-hosted
    steps:
      - name: Pull latest
        run: git -C /home/adipu/LabWise pull

      - name: Install dependencies
        env:
          PATH: /home/adipu/.local/node20/bin:/usr/bin:/bin
        run: |
          npm install --prefix /home/adipu/LabWise/server
          npm audit fix --prefix /home/adipu/LabWise/server
          npm install --prefix /home/adipu/LabWise
          npm audit fix --prefix /home/adipu/LabWise

      - name: Restart app
        run: XDG_RUNTIME_DIR=/run/user/1000 systemctl --user restart labwise-app
