1+ on :
2+ workflow_dispatch :
3+ push :
4+ # Run when commits are pushed to mainline branch (main or master)
5+ # Set this to the mainline branch you are using
6+ branches :
7+ - main
8+ - master
9+
10+ # GitHub Actions workflow to deploy to Azure using azd
11+ # To configure required secrets for connecting to Azure, simply run `azd pipeline config`
12+
13+ # Set up permissions for deploying with secretless Azure federated credentials
14+ # https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Clinux#set-up-azure-login-with-openid-connect-authentication
15+ permissions :
16+ id-token : write
17+ contents : read
18+
19+ jobs :
20+ build :
21+ runs-on : ubuntu-latest
22+ env :
23+ AZURE_CLIENT_ID : ${{ vars.AZURE_CLIENT_ID }}
24+ AZURE_TENANT_ID : ${{ vars.AZURE_TENANT_ID }}
25+ AZURE_SUBSCRIPTION_ID : ${{ vars.AZURE_SUBSCRIPTION_ID }}
26+ AZURE_ENV_NAME : ${{ vars.AZURE_ENV_NAME }}
27+ AZURE_LOCATION : ${{ vars.AZURE_LOCATION }}
28+ steps :
29+ - name : Checkout
30+ uses : actions/checkout@v4
31+
32+ - name : Install azd
33+ 34+
35+ - name : Log in with Azure (Federated Credentials)
36+ if : ${{ env.AZURE_CLIENT_ID != '' }}
37+ run : |
38+ azd auth login `
39+ --client-id "$Env:AZURE_CLIENT_ID" `
40+ --federated-credential-provider "github" `
41+ --tenant-id "$Env:AZURE_TENANT_ID"
42+ shell : pwsh
43+
44+ - name : Log in with Azure (Client Credentials)
45+ if : ${{ env.AZURE_CREDENTIALS != '' }}
46+ run : |
47+ $info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
48+ Write-Host "::add-mask::$($info.clientSecret)"
49+
50+ azd auth login `
51+ --client-id "$($info.clientId)" `
52+ --client-secret "$($info.clientSecret)" `
53+ --tenant-id "$($info.tenantId)"
54+ shell : pwsh
55+ env :
56+ AZURE_CREDENTIALS : ${{ secrets.AZURE_CREDENTIALS }}
57+
58+ - name : Provision Infrastructure
59+ run : azd provision --no-prompt
60+ env :
61+ AZD_INITIAL_ENVIRONMENT_CONFIG : ${{ secrets.AZD_INITIAL_ENVIRONMENT_CONFIG }}
62+
63+ - name : Deploy Application
64+ run : azd deploy --no-prompt
0 commit comments