name: Deploy HiHala Dashboard
on:
  push:
    branches: [main, master]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      
      - name: Build frontend
        env:
          VITE_NOCODB_URL: ${{ secrets.VITE_NOCODB_URL }}
          VITE_NOCODB_TOKEN: ${{ secrets.VITE_NOCODB_TOKEN }}
          VITE_NOCODB_BASE_ID: ${{ secrets.VITE_NOCODB_BASE_ID }}
        run: |
          npm ci
          npm run build
      
      - name: Deploy to server
        run: |
          rsync -a --delete build/ /opt/apps/hihala-dashboard/build/
