name: Deploy To Development

on:
  push:
    branches:
      - develop
  pull_request:
    types: [ opened, synchronize, reopened, closed ]
    branches:
      - develop

jobs:
  build_and_deploy_job:
    if: github.event_name == 'push'
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_CALM_MUD_04916B210 }}
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          action: "upload"
          app_location: "Web"
          api_location: ""
          output_location: "./wwwroot"

  test_deployed_website:
    name: Test Deployed Website
    needs: build_and_deploy_job
    if: github.event_name == 'push'
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./TestAutomation
    steps:
    - uses: browser-actions/setup-geckodriver@latest
    - uses: actions/checkout@v3
    - name: Setup .NET
      uses: actions/setup-dotnet@v2
      with:
        dotnet-version: 6.0.*
    - run: dotnet restore
    - run: dotnet build --no-restore
    - run: dotnet test --no-build --verbosity normal
      env:
        TEST_HOOK: ${{ secrets.TEST_HOOK }}
