Deploy All Demo Apps #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 All Demo Apps | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| id-token: write | |
| contents: read | |
| env: | |
| LOCATION: canadacentral | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| environment: prod | |
| strategy: | |
| matrix: | |
| app: | |
| - { name: 'cq-demo-app-001', rg: 'rg-cq-demo-001', dir: 'cq-demo-app-001' } | |
| - { name: 'cq-demo-app-002', rg: 'rg-cq-demo-002', dir: 'cq-demo-app-002' } | |
| - { name: 'cq-demo-app-003', rg: 'rg-cq-demo-003', dir: 'cq-demo-app-003' } | |
| - { name: 'cq-demo-app-004', rg: 'rg-cq-demo-004', dir: 'cq-demo-app-004' } | |
| - { name: 'cq-demo-app-005', rg: 'rg-cq-demo-005', dir: 'cq-demo-app-005' } | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Azure Login | |
| uses: azure/login@v2 | |
| with: | |
| client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
| tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
| subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
| - name: Create Resource Group | |
| run: az group create --name ${{ matrix.app.rg }} --location ${{ env.LOCATION }} | |
| - name: Deploy Infrastructure | |
| id: infra | |
| working-directory: ${{ matrix.app.dir }} | |
| run: | | |
| outputs=$(az deployment group create \ | |
| --resource-group ${{ matrix.app.rg }} \ | |
| --template-file infra/main.bicep \ | |
| --parameters appName=${{ matrix.app.name }} \ | |
| --query 'properties.outputs' -o json) | |
| echo "acrName=$(echo $outputs | jq -r '.acrName.value')" >> $GITHUB_OUTPUT | |
| echo "appServiceName=$(echo $outputs | jq -r '.appServiceName.value')" >> $GITHUB_OUTPUT | |
| - name: Build and Push to ACR | |
| working-directory: ${{ matrix.app.dir }} | |
| run: | | |
| az acr build \ | |
| --registry ${{ steps.infra.outputs.acrName }} \ | |
| --image ${{ matrix.app.name }}:${{ github.sha }} \ | |
| --image ${{ matrix.app.name }}:latest \ | |
| . | |
| - name: Deploy to Web App | |
| uses: azure/webapps-deploy@v3 | |
| with: | |
| app-name: ${{ steps.infra.outputs.appServiceName }} | |
| images: ${{ steps.infra.outputs.acrName }}.azurecr.io/${{ matrix.app.name }}:${{ github.sha }} | |
| - name: Health Check | |
| run: | | |
| APP_URL=$(az webapp show -g ${{ matrix.app.rg }} -n ${{ steps.infra.outputs.appServiceName }} --query defaultHostName -o tsv) | |
| sleep 60 | |
| curl -sf --retry 10 --retry-delay 15 --retry-all-errors "https://$APP_URL" || exit 1 | |
| - name: Summary | |
| run: | | |
| APP_URL=$(az webapp show -g ${{ matrix.app.rg }} -n ${{ steps.infra.outputs.appServiceName }} --query defaultHostName -o tsv) | |
| echo "### ✅ ${{ matrix.app.name }}" >> $GITHUB_STEP_SUMMARY | |
| echo "Deployed to: https://$APP_URL" >> $GITHUB_STEP_SUMMARY |