name: Publish Docs
on:
  workflow_dispatch:

  release:
    types: [published]

permissions:
  contents: write

jobs:
  deploy_docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: 3.x
      - run: pip install mkdocs-material requests pyyaml

      - name: Generate Helm Chart Index
        run: python ./scripts/generate-helm-index.py > ./frontend/docs/docs/helm-repo/index.yaml

      - name: Copy Docs Files
        run: frontend/docs/copy-api-docs.sh
        env:
          DOCS_SOURCE_URL: https://app.browsertrix.com
          ENABLE_ANALYTICS: true

      - name: Build Docs
        run: cd frontend/docs; mkdocs gh-deploy --force
        env:
          ENABLE_ANALYTICS: true
