44 push :
55 branches : [ main ]
66
7+ # Required block for OIDC token to be used for Azure CLI
8+ permissions :
9+ id-token : write
10+ contents : read
11+
712# This workflow/action uses the Azure CLI to publish the webapp to a staging slot
813# then tests the app to ensure the app is functioning in that staging slot
914# If successfull, the workflow continues on and does a slot-swap.
1722 - name : Git checkout
1823 uses : actions/checkout@v2
1924
25+ # Installs the CLI-beta in a python venv
26+ - name : Installing CLI-beta for OpenID Connect
27+ run : |
28+ cd ../..
29+ CWD="$(pwd)"
30+ python3 -m venv oidc-venv
31+ . oidc-venv/bin/activate
32+ echo "activated environment"
33+ python3 -m pip install -q --upgrade pip
34+ echo "started installing cli beta"
35+ pip install -q --extra-index-url https://azcliprod.blob.core.windows.net/beta/simple/ azure-cli
36+ echo "***************installed cli beta*******************"
37+ echo "$CWD/oidc-venv/bin" >> $GITHUB_PATH
38+
39+ # Logs into Azure via OIDC (note no password)
40+ - name : ' Az OIDC CLI login'
41+ 42+ with :
43+ client-id : ${{ secrets.AZURE_CLIENTID }}
44+ tenant-id : ${{ secrets.AZURE_TENANTID }}
45+ subscription-id : ${{ secrets.AZURE_SUBSCRIPTIONID }}
46+ # Name of the environment. Supported values are azurecloud, azurestack, azureusgovernment, azurechinacloud, azuregermancloud. Default being azurecloud
47+ # environment: azurecloud
48+
2049 - name : Setup dotnet 6.0.x
2150 uses : actions/setup-dotnet@v1
2251 with :
@@ -30,19 +59,16 @@ jobs:
3059
3160 - name : dotnet publish
3261 run : dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp --no-build
33-
34- - name : Azure WebApp Deploy
35- uses : Azure/webapps-deploy@v2
36- with :
37- # Name of the Azure Web App
38- app-name : ${{secrets.APP_NAME}}
39- # Applies to Web Apps(Windows and Linux) and Web App Containers(linux). Multi container scenario not supported. Publish profile (*.publishsettings) file contents with Web Deploy secrets
40- publish-profile : ${{secrets.AZUREWEBAPPPUBLISHPROFILE_STAGE}}
41- # Enter an existing Slot other than the Production slot
42- slot-name : stage
43- # Applies to Web App only: Path to package or folder. *.zip, *.war, *.jar or a folder to deploy
44- package : ${{env.DOTNET_ROOT}}/myapp
45-
62+
63+ - name : zip package
64+ run : |
65+ cd ${{env.DOTNET_ROOT}}/myapp
66+ zip -r myapp.zip .
67+
68+ # Publishes the app to the staging slot
69+ - name : Azure CLI Publish
70+ run : az webapp deployment source config-zip -g rgDoNotDeleteDemos -n ${{secrets.APP_NAME}} --slot stage --src ${{env.DOTNET_ROOT}}/myapp/myapp.zip
71+
4672 test :
4773 name : Test Staging Slot
4874 runs-on : ubuntu-latest
@@ -69,21 +95,32 @@ jobs:
6995 runs-on : ubuntu-latest
7096 needs : test
7197 steps :
72- - name : Azure Login
73- uses : Azure/login@v1
98+ # Installs the CLI-beta in a python venv
99+ - name : Installing CLI-beta for OpenID Connect
100+ run : |
101+ cd ../..
102+ CWD="$(pwd)"
103+ python3 -m venv oidc-venv
104+ . oidc-venv/bin/activate
105+ echo "activated environment"
106+ python3 -m pip install -q --upgrade pip
107+ echo "started installing cli beta"
108+ pip install -q --extra-index-url https://azcliprod.blob.core.windows.net/beta/simple/ azure-cli
109+ echo "***************installed cli beta*******************"
110+ echo "$CWD/oidc-venv/bin" >> $GITHUB_PATH
111+
112+ # Logs into Azure via OIDC (note no password)
113+ - name : ' Az OIDC CLI login'
114+ 74115 with :
75- creds : ${{ secrets.AZURE_CREDENTIALS }}
76- enable-AzPSSession : false
116+ client-id : ${{ secrets.AZURE_CLIENTID }}
117+ tenant-id : ${{ secrets.AZURE_TENANTID }}
118+ subscription-id : ${{ secrets.AZURE_SUBSCRIPTIONID }}
77119 # Name of the environment. Supported values are azurecloud, azurestack, azureusgovernment, azurechinacloud, azuregermancloud. Default being azurecloud
78- # environment: azureusgovernment
120+ # environment: azurecloud
79121
80122 - name : Azure Publish to Staging
81- 82- with :
83- # Specify the script here
84- inlineScript : az webapp deployment slot swap --name ${{secrets.APP_NAME}} --resource-group ${{secrets.APP_RG}} --slot stage --target-slot production
85-
86-
123+ run : az webapp deployment slot swap --name ${{secrets.APP_NAME}} --resource-group ${{secrets.APP_RG}} --slot stage --target-slot production
87124
88125
89126
0 commit comments