name: "Preview on nextstrain.org"
on:
  pull_request:
    types:
      - opened
      - synchronize
      - reopened
      - labeled
      - closed

jobs:
  run:
    # Run if PR has the label and is updated or is newly labeled with the label
    if: |
      (github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'preview on nextstrain.org')) ||
      (github.event.action == 'labeled' && github.event.label.name == 'preview on nextstrain.org')
    uses: ./.github/workflows/preview_on_downstream_repo.yaml
    secrets: inherit
    with:
      repository: nextstrain/nextstrain.org
      directory: auspice-client
      cleanup: ${{ github.event.action == 'closed' }}
