name: 🚀 Deploy website on push to prod
on:
  push:
    branches:
      - master
jobs:
  deploy-dev:
    name: 🎉 Deploy
    runs-on: ubuntu-latest
    steps:
      - name: 🚚 Get latest code
        uses: actions/checkout@v4

      - uses: pnpm/action-setup@v4
        name: Install pnpm
        with:
          version: 10
          run_install: false

      - name: Install Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: 'pnpm'

      - name: Get pnpm store directory
        shell: bash
        run: |
          echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

      - uses: actions/cache@v4
        name: Setup pnpm cache
        with:
          path: ${{ env.STORE_PATH }}
          key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
          restore-keys: |
            ${{ runner.os }}-pnpm-store-

      - name: Install dependencies (with cache)
        run: pnpm install

      - name: 🔨 Build Project
        run: pnpm build

      - name: 📂 Sync files
        uses: SamKirkland/FTP-Deploy-Action@v4.3.4
        with:
          server: mangos77.com
          username: FTP_USERNAME
          password: ${{ secrets.FTP_PASSWORD }}
          port: 2121
          local-dir: ./dist/browser/
          server-dir: ./
          dry-run: true
          exclude: |
            **/.git*
            **/.git*/**
            **/node_modules/**
            **/DEV/**
