# Pages

- Object ID: `em:automation:sha256:5715a2e1c34e3fbde0b1c696674556b8b3a3c1b965e5b522769028ae3cab1dc3`
- Kind: `automation`
- Repository path: [`.github/workflows/pages.yml`](https://github.com/yoheinakajima/epistemedia/blob/f92846570180dfa4511263f8ba98ecd18f7772c9/.github/workflows/pages.yml)
- Content digest: `c130385f859ba2f3ee3ceda5d3a192eb203a2f078fef730926a1efa6af8e684e`

**Also filed under:** [Agent Operations](https://epistemedia.org/topics/agent-operations/), [Human and Agent Interfaces](https://epistemedia.org/topics/public-interfaces/), [Releases and Reproducibility](https://epistemedia.org/topics/releases/)

## Source content

name: publish-pages

on:
  workflow_dispatch:
    inputs:
      deployment_mode:
        description: Publish at the GitHub hostname first; attach the custom domain only after DNS is ready.
        required: true
        default: bootstrap
        type: choice
        options:
          - bootstrap
          - custom-domain

permissions: {}

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

jobs:
  build:
    if: github.repository == 'yoheinakajima/epistemedia' && github.ref == 'refs/heads/main'
    permissions:
      contents: read
      pages: read
    runs-on: ubuntu-latest
    timeout-minutes: 20
    env:
      EPISTEMEDIA_BASE_URL: ${{ inputs.deployment_mode == 'custom-domain' && 'https://epistemedia.org' || 'https://yoheinakajima.github.io/epistemedia' }}
    steps:
      - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
        with:
          fetch-depth: 0
          persist-credentials: false
      - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
        with:
          python-version: "3.12"
          cache: pip
      - run: python -m pip install -e '.[dev]'
      - name: Validate, build, test, audit
        run: |
          python -m epistemedia validate
          python -m epistemedia build --output generated/public --base-url "$EPISTEMEDIA_BASE_URL" --api-url https://api.epistemedia.org/v1 --mcp-url https://mcp.epistemedia.org/mcp
          python -m pytest -q
          python -m epistemedia audit --public generated/public
      - name: Attach custom domain
        if: inputs.deployment_mode == 'custom-domain'
        run: printf '%s\n' epistemedia.org > generated/public/CNAME
      - name: Keep bootstrap independent from custom-domain DNS
        if: inputs.deployment_mode == 'bootstrap'
        run: test ! -e generated/public/CNAME
      - uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6
      - uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5
        with:
          path: generated/public
          include-hidden-files: true
  deploy:
    permissions:
      pages: write
      id-token: write
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Deploy
        id: deployment
        uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5
