Fix optional Azure Monitor import for CI #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy API to Azure Container Apps | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "app.py" | |
| - "src/**" | |
| - "data/**" | |
| - "benchmarks/_results/**" | |
| - "deploy/Dockerfile" | |
| - "requirements.txt" | |
| - "pyproject.toml" | |
| - ".github/workflows/deploy-azure.yml" | |
| concurrency: | |
| group: deploy-azure-${{ github.ref }} | |
| cancel-in-progress: false | |
| permissions: | |
| id-token: write | |
| contents: read | |
| env: | |
| IMAGE_NAME: sit-api | |
| jobs: | |
| deploy: | |
| name: Build, push, and deploy API | |
| runs-on: ubuntu-latest | |
| environment: production | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Azure login via OIDC | |
| uses: azure/login@v2 | |
| with: | |
| client-id: ${{ vars.AZURE_CLIENT_ID }} | |
| tenant-id: ${{ vars.AZURE_TENANT_ID }} | |
| subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }} | |
| - name: Resolve ACR login server | |
| id: acr | |
| shell: bash | |
| run: | | |
| LOGIN_SERVER=$(az acr show \ | |
| --name "${{ vars.AZURE_CONTAINER_REGISTRY }}" \ | |
| --resource-group "${{ vars.AZURE_RESOURCE_GROUP }}" \ | |
| --query loginServer \ | |
| --output tsv) | |
| echo "login_server=$LOGIN_SERVER" >> "$GITHUB_OUTPUT" | |
| - name: Log in to ACR | |
| shell: bash | |
| run: az acr login --name "${{ vars.AZURE_CONTAINER_REGISTRY }}" | |
| - name: Build image | |
| shell: bash | |
| run: | | |
| docker build \ | |
| -f deploy/Dockerfile \ | |
| -t "${{ steps.acr.outputs.login_server }}/${{ env.IMAGE_NAME }}:${{ github.sha }}" \ | |
| -t "${{ steps.acr.outputs.login_server }}/${{ env.IMAGE_NAME }}:latest" \ | |
| . | |
| - name: Push image | |
| shell: bash | |
| run: | | |
| docker push "${{ steps.acr.outputs.login_server }}/${{ env.IMAGE_NAME }}:${{ github.sha }}" | |
| docker push "${{ steps.acr.outputs.login_server }}/${{ env.IMAGE_NAME }}:latest" | |
| - name: Update Container App image | |
| shell: bash | |
| run: | | |
| az containerapp update \ | |
| --name "${{ vars.AZURE_CONTAINER_APP }}" \ | |
| --resource-group "${{ vars.AZURE_RESOURCE_GROUP }}" \ | |
| --image "${{ steps.acr.outputs.login_server }}/${{ env.IMAGE_NAME }}:${{ github.sha }}" \ | |
| --set-env-vars SIT_GIT_SHA="${{ github.sha }}" | |
| - name: Resolve public API URL | |
| id: api | |
| shell: bash | |
| run: | | |
| FQDN=$(az containerapp show \ | |
| --name "${{ vars.AZURE_CONTAINER_APP }}" \ | |
| --resource-group "${{ vars.AZURE_RESOURCE_GROUP }}" \ | |
| --query properties.configuration.ingress.fqdn \ | |
| --output tsv) | |
| echo "fqdn=$FQDN" >> "$GITHUB_OUTPUT" | |
| echo "API URL: https://$FQDN" | |
| - name: Smoke test health endpoint | |
| shell: bash | |
| run: | | |
| curl --fail --show-error --retry 12 --retry-all-errors --retry-delay 10 \ | |
| "https://${{ steps.api.outputs.fqdn }}/api/v1/health" |