name: Azure Static Web Apps CI/CD

pr: none
trigger:
  branches:
    include:
      - dev

jobs:
- job: build_and_deploy_job
  displayName: Build and Deploy Job
  condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI')))
  pool:
    vmImage: ubuntu-latest
  variables:
  - group: Azure-Static-Web-Apps-nice-bay-0ad032c03-variable-group
  steps:
  - checkout: self
    submodules: true

  - script: |
      python -m pip install --upgrade pip==23.0.1
      pip install wheel==0.38.4 --upgrade
      pip install setuptools==66 --upgrade
      pip install build==0.10.0
    displayName: 'Install build dependencies'

  - script: |
      pip install -e .[dev,rl]
    displayName: 'Install PrimAITE for docs autosummary'

  - script: |
      sudo apt-get install pandoc
    displayName: 'Install Pandoc'

  - script: |
      primaite setup
    displayName: 'Perform PrimAITE Setup'

  - script: |
      cd docs
      make html
      cd ..
      cd ..
    displayName: 'Build Docs'

  - task: AzureStaticWebApp@0
    inputs:
      azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN_NICE_BAY_0AD032C03)
      app_location: "/docs/_build/html"
      api_location: ""
      output_location: "/"
    displayName: 'Deploy Docs to nice-bay-0ad032c03'
