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