name: Deploy Website

on:
  push:
    branches: [main]
    paths:
      - 'website/**'
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup pnpm
        uses: pnpm/action-setup@v4
        with:
          version: 9

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 22

      - name: Install dependencies
        working-directory: website
        run: pnpm install

      - name: Build
        working-directory: website
        run: pnpm build

      - name: Deploy to host volume
        run: |
          rm -rf /home/debian/my-services/cagire-website-data/*
          cp -r website/dist/* /home/debian/my-services/cagire-website-data/
