Skip to content

Refactor smoke test script in workflow.yml #54

Refactor smoke test script in workflow.yml

Refactor smoke test script in workflow.yml #54

Workflow file for this run

name: deploy-auto-website-suite
concurrency: auto-bicep
on:
push:
branches:
- main
permissions:
id-token: write
contents: read
env:
AZURE_RESOURCEGROUP_NAME: rg_sb_eastus_89803_1_171079247255
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Bicep linter
run: az bicep build --file main.bicep
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: azure/login@v1
name: Sign in to Azure
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- uses: azure/arm-deploy@v1
name: Run preflight validation
with:
deploymentName: ${{ github.run_number }}
resourceGroupName: ${{ env.AZURE_RESOURCEGROUP_NAME }}
template: main.bicep
parameters: main.parameters.json
deploymentMode: Validate
preview:
runs-on: ubuntu-latest
needs: [lint, validate]
steps:
- uses: actions/checkout@v3
- uses: azure/login@v1
name: Sign in to Azure
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- uses: azure/arm-deploy@v1
name: Run what-if
with:
scope: resourcegroup
failOnStdErr: false
resourceGroupName: ${{ env.AZURE_RESOURCEGROUP_NAME }}
template: main.bicep
parameters: main.parameters.json
additionalArguments: --what-if
deploy:
runs-on: ubuntu-latest
environment: Azure
needs: preview
outputs:
appServiceDefaultHostName: ${{ steps.deploy.outputs.appServiceDefaultHostName }}
steps:
- uses: actions/checkout@v3
- uses: azure/login@v1
name: Sign in to Azure
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- uses: azure/arm-deploy@v1
id: deploy
name: Deploy website
with:
failOnStdErr: false
deploymentName: ${{ github.run_number }}
resourceGroupName: ${{ env.AZURE_RESOURCEGROUP_NAME }}
template: main.bicep
parameters: main.parameters.json
smoke-test:
runs-on: ubuntu-latest
needs: deploy
steps:
- uses: actions/checkout@v3
- run: |
Invoke-Pester `
-Script @{ Path = 'Website.Tests.ps1'; Parameters = @{ HostName = '${{needs.deploy.outputs.appServiceDefaultHostName}}' } } `
-CI
name: Run smoke tests
shell: pwsh