name: Deploy Presentation

on:
  push:
    branches: [main]
  workflow_dispatch:
    inputs:
      dry_run:
        description: 'Dry run (preview only)'
        required: false
        default: 'false'
        type: boolean

jobs:
  deploy:
    name: Build and Deploy
    runs-on: ubuntu-latest

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

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'

      - name: Install dependencies
        run: npm ci

      - name: Build presentation
        run: npx brixon build

      - name: Deploy presentation
        if: ${{ github.event.inputs.dry_run != 'true' }}
        run: npx brixon deploy
        env:
          BRIXON_API_KEY: ${{ secrets.BRIXON_API_KEY }}

      - name: Deploy preview (dry run)
        if: ${{ github.event.inputs.dry_run == 'true' }}
        run: npx brixon deploy --dry-run
        env:
          BRIXON_API_KEY: ${{ secrets.BRIXON_API_KEY }}
