name: Client Client

on:
  push:
    branches: [master]
    paths:
      - 'Client-Client/**'
      - '.gitea/workflows/client-client.yml'

jobs:
  build-deploy:
    runs-on: host
    env:
      NGINX_HOST: 192.168.77.227
      NGINX_PATH: /var/www/positivespend/websites/client
      SSH_KEY: ~/.ssh/gitea_runner

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Install dependencies
        working-directory: Client-Client
        run: npm ci

      - name: Build
        working-directory: Client-Client
        run: npm run build

      - name: Deploy to Nginx server
        run: |
          rsync -az --delete \
            -e "ssh -i ${{ env.SSH_KEY }} -o StrictHostKeyChecking=no" \
            Client-Client/dist/ \
            root@${{ env.NGINX_HOST }}:${{ env.NGINX_PATH }}/
