Skip to content

Commit 520c509

Browse files
committed
Merge branch 'main' of https://github.com/joelbyford/QrCodeApiApp into TestFixes
2 parents c1b49d2 + ec1aa27 commit 520c509

File tree

3 files changed

+97
-36
lines changed

3 files changed

+97
-36
lines changed

.github/workflows/main-pr.yml

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,41 @@ on:
44
pull_request:
55
branches: [ main ]
66

7+
permissions:
8+
id-token: write
9+
contents: read
10+
711
jobs:
812
build:
913
name: Build To Dev Slot
1014
runs-on: ubuntu-latest
1115
steps:
1216
- name: Git checkout
1317
uses: actions/checkout@v2
18+
19+
# Installs the CLI-beta in a python venv
20+
- name: Installing CLI-beta for OpenID Connect
21+
run: |
22+
cd ../..
23+
CWD="$(pwd)"
24+
python3 -m venv oidc-venv
25+
. oidc-venv/bin/activate
26+
echo "activated environment"
27+
python3 -m pip install -q --upgrade pip
28+
echo "started installing cli beta"
29+
pip install -q --extra-index-url https://azcliprod.blob.core.windows.net/beta/simple/ azure-cli
30+
echo "***************installed cli beta*******************"
31+
echo "$CWD/oidc-venv/bin" >> $GITHUB_PATH
32+
33+
# Logs into Azure via OIDC (note no password)
34+
- name: 'Az OIDC CLI login'
35+
uses: azure/[email protected]
36+
with:
37+
client-id: ${{ secrets.AZURE_CLIENTID }}
38+
tenant-id: ${{ secrets.AZURE_TENANTID }}
39+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTIONID }}
40+
# Name of the environment. Supported values are azurecloud, azurestack, azureusgovernment, azurechinacloud, azuregermancloud. Default being azurecloud
41+
# environment: azurecloud
1442

1543
- name: Setup dotnet 6.0.x
1644
uses: actions/setup-dotnet@v1
@@ -26,17 +54,13 @@ jobs:
2654
- name: dotnet publish
2755
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
2856

29-
- name: Azure WebApp Deploy
30-
uses: Azure/webapps-deploy@v2
31-
with:
32-
# Name of the Azure Web App
33-
app-name: ${{secrets.APP_NAME}}
34-
# 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
35-
publish-profile: ${{secrets.AZUREWEBAPPPUBLISHPROFILE_TEST}}
36-
# Enter an existing Slot other than the Production slot
37-
slot-name: test
38-
# Applies to Web App only: Path to package or folder. *.zip, *.war, *.jar or a folder to deploy
39-
package: ${{env.DOTNET_ROOT}}/myapp
57+
- name: zip package
58+
run: |
59+
cd ${{env.DOTNET_ROOT}}/myapp
60+
zip -r myapp.zip .
61+
62+
- name: Azure CLI Publish
63+
run: az webapp deployment source config-zip -g rgDoNotDeleteDemos -n ${{secrets.APP_NAME}} --slot test --src ${{env.DOTNET_ROOT}}/myapp/myapp.zip
4064

4165
test:
4266
name: Smoke Test Dev Slot

.github/workflows/main-push.yml

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ on:
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.
@@ -17,6 +22,30 @@ jobs:
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+
uses: azure/[email protected]
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+
uses: azure/[email protected]
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-
uses: Azure/[email protected]
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

QrCodeApiApp/QrCodeApiApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<ItemGroup>
1212
<PackageReference Include="joelbyford.BasicAuth" Version="1.2.0" />
13-
<PackageReference Include="Microsoft.OpenApi" Version="1.6.13" />
13+
<PackageReference Include="Microsoft.OpenApi" Version="1.4.3" />
1414
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
1515
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
1616
<PackageReference Include="ZXing.Net" Version="0.16.9" />

0 commit comments

Comments
 (0)