# File: .gitea/workflows/deploy.yml
name: Build and Deploy Hugo Site to Cloudron

# This action runs on every 'push' to the 'main' branch
on:
  push:
    branches:
      - main

jobs:
  build-and-deploy:
    # 'ubuntu-latest' is a standard label.
    runs-on: ubuntu-latest

    steps:
      # Step 1: Check out your repository's code
      - name: Check out code
        uses: actions/checkout@v4
        with:
          # Still critical for fetching your theme
          submodules: true

      # Step 2: Set up the Hugo environment
      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: 'latest'

      # Step 3: Build your site
      - name: Build Hugo Site
        run: hugo --minify
        
      # Step 4: Download the standalone Surfer CLI
      - name: Download Surfer CLI
        run: |
          curl -L "https://cloudron.io/surfer-cli/linux/x64/surfer" -o surfer
          chmod +x surfer

      # Step 5: Deploy using the Surfer CLI
      # This is the simple, direct method you found.
      - name: Deploy to Cloudron Surfer
        run: |
          echo "Deploying to ${{ secrets.SURFER_APP_DOMAIN }}..."
          ./surfer put \
            --token ${{ secrets.SURFER_TOKEN }} \
            --server ${{ secrets.SURFER_APP_DOMAIN }} \
            ./public/* /