name: Deploy to Production

on:
  push:
    branches:
      - master

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install lftp
        run: |
          apt-get update
          apt-get install -y lftp

      - name: Deploy to Production Server (FTP)
        run: |
          echo "🚀 Deploying to Production..."
          lftp -c "
            set ftp:ssl-allow no
            set ftp:passive-mode yes
            open -u ${FTP_USER},${FTP_PASS} ${FTP_HOST}
            mirror -R --delete --verbose \
              --exclude-glob .git/ \
              --exclude-glob .gitea/ \
              --exclude-glob .gitignore \
              --exclude-glob designs/ \
              ./ ${TARGET_DIR}
          "
        env:
          FTP_HOST: ${{ secrets.FTP_HOST }}
          FTP_USER: ${{ secrets.FTP_USER }}
          FTP_PASS: ${{ secrets.FTP_PASS }}
          TARGET_DIR: ${{ secrets.TARGET_DIR }}
