# Cloudflare Pages Deploy Workflow
#
# PREREQUISITES (must be set up manually before this workflow runs):
# 1. Cloudflare account with the assay.rs domain added as a Zone
# 2. Pages project 'assay-rs' already created (done via wrangler CLI)
# 3. GitHub repository secrets configured:
#    - CLOUDFLARE_API_TOKEN: API token with Cloudflare Pages:Write permission
#    - CLOUDFLARE_ACCOUNT_ID: 042f601c488422312a3cc09e3c4bc6ca
# 4. Custom domain: Pages > assay-rs > Custom domains > Add assay.rs
#
# Project URL: https://assay-rs.pages.dev
# Deploy command: wrangler pages deploy site/ --project-name=assay-rs

name: Deploy to Cloudflare Pages

on:
  push:
    branches:
      - main
    paths:
      - "site/**"
      - "wrangler.toml"

concurrency:
  group: cloudflare-pages-deploy
  cancel-in-progress: false

jobs:
  deploy:
    name: Deploy site to Cloudflare Pages
    runs-on: ubuntu-latest
    permissions:
      contents: read
      deployments: write

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

      - name: Deploy to Cloudflare Pages
        uses: cloudflare/wrangler-action@v3
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          command: pages deploy site/ --project-name=assay-rs
