Skip to content

Fix GH Actions

Fix GH Actions #908

Workflow file for this run

name: Build TodoItems No Docker
on:
schedule:
- cron: '0 0 * * 3'
push:
paths-ignore:
- .azuredevops/**
- .devcontainer/**
- .vscode/**
- .github/dependabot.yml
workflow_dispatch:
inputs:
buildConfiguration:
description: 'Build configuration'
required: true
default: 'Release'
type: choice
options:
- Debug
- Release
defaults:
run:
shell: pwsh
jobs:
determine_variables_build:
permissions:
contents: read
runs-on: ubuntu-latest
outputs:
buildConfiguration: ${{ steps.setupVars.outputs.buildConfiguration }}
steps:
- name: Setup variables
id: setupVars
run: |
if("${{inputs.buildConfiguration}}"){
echo "buildConfiguration=${{inputs.buildConfiguration}}" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
}
else{
echo "buildConfiguration=Release" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
}
build:
needs: [determine_variables_build]
uses: ./.github/workflows/build.yml
with:
buildConfiguration: ${{needs.determine_variables_build.outputs.buildConfiguration}}
secrets: inherit
validate:
needs: [build]
uses: ./.github/workflows/create_env.yml
with:
region: ${{ vars.AZURE_REGION }}
template: /artifacts/bicep/main.nodocker.webapp.bicep
additionalParameters: applicationname=todoitems
deploy: false
secrets: inherit
create_env:
if: inputs.buildConfiguration != ''
needs: [validate]
uses: ./.github/workflows/create_env.yml
with:
region: ${{ vars.AZURE_REGION }}
template: /artifacts/bicep/main.nodocker.webapp.bicep
additionalParameters: applicationname=todoitems
deploy: true
secrets: inherit
deploy_app:
needs: [build, create_env]
runs-on: ubuntu-latest
environment: AzureDeploy
permissions:
id-token: write
contents: read
deployments: write
steps:
- name: Download a Build Artifact
uses: actions/download-artifact@v6
with:
name: todoItemsApi
path: ${{github.workspace}}/artifacts/api
- uses: Azure/login@v2
name: Azure Login
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- run: Compress-Archive -Path ${{github.workspace}}/artifacts/api/* -DestinationPath ${{github.workspace}}/artifacts/api/api.zip
- uses: Azure/cli@v2
name: Azure Deploy WebApp
with:
inlineScript: |
az webapp deploy --src-path ${{github.workspace}}/artifacts/api/api.zip --name ${{ needs.create_env.outputs.webAppName }} --resource-group ${{ needs.create_env.outputs.resourcegroup }} --type zip
az webapp config set --startup-file="dotnet TodoItems.Api.dll" --name ${{ needs.create_env.outputs.webAppName }} --resource-group ${{ needs.create_env.outputs.resourcegroup }}
deploy_db:
needs: [build, create_env]
uses: ./.github/workflows/deploy_db.yml
with:
sqlServerFQDN: ${{needs.create_env.outputs.sqlServerFQDN}}
databaseName: ${{needs.create_env.outputs.databaseName}}
secrets: inherit
smoketests:
needs: [deploy_app, create_env, deploy_db]
uses: ./.github/workflows/smoketests.yml
with:
webAppUrl: ${{needs.create_env.outputs.webAppUrl}}
delete_env:
needs: [create_env, smoketests]
uses: ./.github/workflows/delete_env.yml
with:
resourcegroupName: ${{ needs.create_env.outputs.resourcegroup }}
secrets: inherit