From 7155b441ba5b9bad8bd321205fd753ec23cdaee1 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 19 Dec 2023 06:59:37 -0800 Subject: [PATCH 1/2] Update azure-dev.yaml --- .github/workflows/azure-dev.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/azure-dev.yaml b/.github/workflows/azure-dev.yaml index 1d88107..dd75793 100644 --- a/.github/workflows/azure-dev.yaml +++ b/.github/workflows/azure-dev.yaml @@ -13,8 +13,6 @@ permissions: jobs: build: runs-on: ubuntu-latest - container: - image: mcr.microsoft.com/azure-dev-cli-apps:latest env: AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} @@ -24,6 +22,9 @@ jobs: - name: Checkout uses: actions/checkout@v2 + - name: Install azd + uses: Azure/setup-azd@v0.1.0 + - name: Log in with Azure (Federated Credentials) if: ${{ env.AZURE_CLIENT_ID != '' }} run: | @@ -58,4 +59,4 @@ jobs: env: AZURE_ENV_NAME: ${{ secrets.AZURE_ENV_NAME }} AZURE_LOCATION: ${{ secrets.AZURE_LOCATION }} - AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} \ No newline at end of file + AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} From 1b7f2907385c1bfe9d5cd7b20bc2913ad361c371 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Mon, 8 Apr 2024 06:22:57 -0700 Subject: [PATCH 2/2] Update azure-dev.yaml --- .github/workflows/azure-dev.yaml | 40 ++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/.github/workflows/azure-dev.yaml b/.github/workflows/azure-dev.yaml index dd75793..a7f5674 100644 --- a/.github/workflows/azure-dev.yaml +++ b/.github/workflows/azure-dev.yaml @@ -1,11 +1,16 @@ -name: Azure Developer CLI - on: workflow_dispatch: push: + # Run when commits are pushed to mainline branch (main or master) + # Set this to the mainline branch you are using branches: - main +# GitHub Actions workflow to deploy to Azure using azd +# To configure required secrets for connecting to Azure, simply run `azd pipeline config` + +# Set up permissions for deploying with secretless Azure federated credentials +# https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Clinux#set-up-azure-login-with-openid-connect-authentication permissions: id-token: write contents: read @@ -14,21 +19,21 @@ jobs: build: runs-on: ubuntu-latest env: - AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} - AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} - AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }} + AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }} + AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }} AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install azd - uses: Azure/setup-azd@v0.1.0 + uses: Azure/setup-azd@v1.0.0 - name: Log in with Azure (Federated Credentials) if: ${{ env.AZURE_CLIENT_ID != '' }} run: | - azd login ` + azd auth login ` --client-id "$Env:AZURE_CLIENT_ID" ` --federated-credential-provider "github" ` --tenant-id "$Env:AZURE_TENANT_ID" @@ -39,7 +44,8 @@ jobs: run: | $info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable; Write-Host "::add-mask::$($info.clientSecret)" - azd login ` + + azd auth login ` --client-id "$($info.clientId)" ` --client-secret "$($info.clientSecret)" ` --tenant-id "$($info.tenantId)" @@ -47,16 +53,16 @@ jobs: env: AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} - - name: Azure Dev Provision + - name: Provision Infrastructure run: azd provision --no-prompt env: - AZURE_ENV_NAME: ${{ secrets.AZURE_ENV_NAME }} - AZURE_LOCATION: ${{ secrets.AZURE_LOCATION }} - AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }} + AZURE_LOCATION: ${{ vars.AZURE_LOCATION }} + AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }} - - name: Azure Dev Deploy + - name: Deploy Application run: azd deploy --no-prompt env: - AZURE_ENV_NAME: ${{ secrets.AZURE_ENV_NAME }} - AZURE_LOCATION: ${{ secrets.AZURE_LOCATION }} - AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }} + AZURE_LOCATION: ${{ vars.AZURE_LOCATION }} + AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}