Skip to content

Commit a4c6ef8

Browse files
committed
enable github action login with user assigned identity
1 parent 440425c commit a4c6ef8

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

.github/workflows/aca-deploy.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@ jobs:
2323
steps:
2424
- name: Log in to Azure with service principal
2525
uses: azure/login@v2
26+
if: ${{ vars.AZURE_CLIENT_ID == '' }}
2627
with:
2728
creds: ${{ secrets.AZURE_CREDENTIALS }}
29+
- name: Log in with Azure (Federated Credentials)
30+
if: ${{ vars.AZURE_CLIENT_ID != '' }}
31+
uses: azure/login@v2
32+
with:
33+
client-id: ${{ vars.AZURE_CLIENT_ID }}
34+
tenant-id: ${{ vars.AZURE_TENANT_ID }}
35+
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
2836
- name: Build and deploy Container App
2937
uses: azure/container-apps-deploy-action@v1
3038
with:

.github/workflows/acr-build-push.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,30 @@ jobs:
1717
build:
1818
runs-on: ubuntu-latest
1919
environment: ${{inputs.env-name}}
20+
2021
steps:
2122
- name: Log in to Azure with service principal
23+
if: ${{ vars.AZURE_CLIENT_ID == '' }}
2224
uses: azure/login@v2
2325
with:
2426
creds: ${{ secrets.AZURE_CREDENTIALS }}
2527
- name: Log in Azure Container Registry
28+
if: ${{ vars.AZURE_CLIENT_ID == '' }}
2629
uses: azure/docker-login@v2
2730
with:
2831
login-server: ${{vars.ACR_NAME}}.azurecr.io
2932
username: ${{ secrets.SPI_CLIENT_ID }}
3033
password: ${{ secrets.SPI_CLIENT_SECRET }}
34+
- name: Log in with Azure (Federated Credentials)
35+
if: ${{ vars.AZURE_CLIENT_ID != '' }}
36+
uses: azure/login@v2
37+
with:
38+
client-id: ${{ vars.AZURE_CLIENT_ID }}
39+
tenant-id: ${{ vars.AZURE_TENANT_ID }}
40+
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
41+
- name: Login to Azure Container Registry (Federated Credentials)
42+
if: ${{ vars.AZURE_CLIENT_ID != '' }}
43+
run: az acr login --name ${{vars.ACR_NAME}}
3144
- uses: actions/checkout@v2
3245
- name: Build and Push to ACR
3346
run: |

0 commit comments

Comments
 (0)