|
11 | 11 | SUBSCRIPTION-ID: YOUR-SUBS-ID |
12 | 12 | WEBAPP-NAME: eshoponweb-webapp-NAME |
13 | 13 |
|
14 | | - |
15 | 14 | jobs: |
16 | 15 | #Build, test and publish .net web project in repository |
17 | 16 | buildandtest: |
18 | 17 | runs-on: ubuntu-latest |
19 | 18 | steps: |
20 | | - #checkout the repository |
21 | | - - uses: actions/checkout@v4 |
22 | | - #prepare runner for desired .net version SDK |
23 | | - - name: Setup .NET |
24 | | - uses: actions/setup-dotnet@v4 |
25 | | - with: |
26 | | - dotnet-version: '8.0.x' |
27 | | - dotnet-quality: 'preview' |
28 | | - #Build/Test/Publish the .net project |
29 | | - - name: Build with dotnet |
30 | | - run: dotnet build ./eShopOnWeb.sln --configuration Release |
31 | | - - name: Test with dotnet |
32 | | - run: dotnet test ./eShopOnWeb.sln --configuration Release |
33 | | - - name: dotnet publish |
34 | | - run: | |
35 | | - dotnet publish ./src/Web/Web.csproj -c Release -o ${{env.DOTNET_ROOT}}/myapp |
36 | | - cd ${{env.DOTNET_ROOT}}/myapp |
37 | | - zip -r ../app.zip . |
38 | | - # upload the published website code artifacts |
39 | | - - name: Upload artifact for deployment job |
40 | | - uses: actions/upload-artifact@v4 |
41 | | - with: |
42 | | - name: .net-app |
43 | | - path: ${{env.DOTNET_ROOT}}/app.zip |
44 | | - |
45 | | - # upload the bicep template as artifacts for next job |
46 | | - - name: Upload artifact for deployment job |
47 | | - uses: actions/upload-artifact@v4 |
48 | | - with: |
49 | | - name: bicep-template |
50 | | - path: ${{ env.TEMPLATE-FILE }} |
51 | | - |
52 | | - # Use Bicep to deploy infrastructure + Publish webapp |
| 19 | + #checkout the repository |
| 20 | + - uses: actions/checkout@v5 |
| 21 | + #prepare runner for desired .net version SDK |
| 22 | + - name: Setup .NET |
| 23 | + uses: actions/setup-dotnet@v5 |
| 24 | + with: |
| 25 | + dotnet-version: "8.0.x" |
| 26 | + dotnet-quality: "preview" |
| 27 | + #Build/Test/Publish the .net project |
| 28 | + - name: Build with dotnet |
| 29 | + run: dotnet build ./eShopOnWeb.sln --configuration Release |
| 30 | + - name: Test with dotnet |
| 31 | + run: dotnet test ./eShopOnWeb.sln --configuration Release |
| 32 | + - name: dotnet publish |
| 33 | + run: | |
| 34 | + dotnet publish ./src/Web/Web.csproj -c Release -o ${{env.DOTNET_ROOT}}/myapp |
| 35 | + cd ${{env.DOTNET_ROOT}}/myapp |
| 36 | + zip -r ../app.zip . |
| 37 | + # upload the published website code artifacts |
| 38 | + - name: Upload artifact for deployment job |
| 39 | + uses: actions/upload-artifact@v5 |
| 40 | + with: |
| 41 | + name: .net-app |
| 42 | + path: ${{env.DOTNET_ROOT}}/app.zip |
| 43 | + |
| 44 | + # upload the bicep template as artifacts for next job |
| 45 | + - name: Upload artifact for deployment job |
| 46 | + uses: actions/upload-artifact@v5 |
| 47 | + with: |
| 48 | + name: bicep-template |
| 49 | + path: ${{ env.TEMPLATE-FILE }} |
| 50 | + |
| 51 | + # Use Bicep to deploy infrastructure + Publish webapp |
53 | 52 | deploy: |
54 | 53 | runs-on: ubuntu-latest |
55 | 54 | needs: buildandtest |
56 | 55 | environment: |
57 | | - name: 'Development' |
| 56 | + name: "Development" |
58 | 57 | steps: |
59 | | - |
60 | | - #Download the publish files created in previous job |
61 | | - - name: Download artifact from build job |
62 | | - uses: actions/download-artifact@v4 |
63 | | - with: |
64 | | - name: .net-app |
65 | | - path: .net-app |
66 | | - |
67 | | - #Download the bicep templates from previous job |
68 | | - - name: Download artifact from build job |
69 | | - uses: actions/download-artifact@v4 |
70 | | - with: |
71 | | - name: bicep-template |
72 | | - path: bicep-template |
73 | | - |
74 | | - #Login in your azure subscription using a service principal (credentials stored as GitHub Secret in repo) |
75 | | - - name: Azure Login |
76 | | - uses: azure/login@v2 |
77 | | - with: |
78 | | - creds: ${{ secrets.AZURE_CREDENTIALS }} |
79 | | - |
80 | | - # Deploy Azure WebApp using Bicep file |
81 | | - - name: deploy |
82 | | - uses: azure/arm-deploy@v2 |
83 | | - with: |
84 | | - subscriptionId: ${{ env.SUBSCRIPTION-ID }} |
85 | | - resourceGroupName: ${{ env.RESOURCE-GROUP }} |
86 | | - template: bicep-template/webapp.bicep |
87 | | - parameters: 'webAppName=${{ env.WEBAPP-NAME }} location=${{ env.LOCATION }}' |
88 | | - failOnStdErr: false |
89 | | - |
90 | | - # Publish website to Azure App Service (WebApp) |
91 | | - # Step disabled due to issue where the site sometimes can't be found: https://github.com/microsoft/pipelines-appservice-lib/issues/56. Instead deploy using CLI |
92 | | - - name: Publish Website to WebApp |
93 | | - if: false #Disable step due to comment above |
94 | | - uses: Azure/webapps-deploy@v3 |
95 | | - with: |
96 | | - type: ZIP |
97 | | - app-name: ${{ env.WEBAPP-NAME }} |
98 | | - package: .net-app/app.zip |
| 58 | + #Download the publish files created in previous job |
| 59 | + - name: Download artifact from build job |
| 60 | + uses: actions/download-artifact@v6 |
| 61 | + with: |
| 62 | + name: .net-app |
| 63 | + path: .net-app |
| 64 | + |
| 65 | + #Download the bicep templates from previous job |
| 66 | + - name: Download artifact from build job |
| 67 | + uses: actions/download-artifact@v6 |
| 68 | + with: |
| 69 | + name: bicep-template |
| 70 | + path: bicep-template |
| 71 | + |
| 72 | + #Login in your azure subscription using a service principal (credentials stored as GitHub Secret in repo) |
| 73 | + - name: Azure Login |
| 74 | + uses: azure/login@v2 |
| 75 | + with: |
| 76 | + creds: ${{ secrets.AZURE_CREDENTIALS }} |
| 77 | + |
| 78 | + # Deploy Azure WebApp using Bicep file |
| 79 | + - name: deploy |
| 80 | + uses: azure/arm-deploy@v2 |
| 81 | + with: |
| 82 | + subscriptionId: ${{ env.SUBSCRIPTION-ID }} |
| 83 | + resourceGroupName: ${{ env.RESOURCE-GROUP }} |
| 84 | + template: bicep-template/webapp.bicep |
| 85 | + parameters: "webAppName=${{ env.WEBAPP-NAME }} location=${{ env.LOCATION }}" |
| 86 | + failOnStdErr: false |
| 87 | + |
| 88 | + # Publish website to Azure App Service (WebApp) |
| 89 | + # Step disabled due to issue where the site sometimes can't be found: https://github.com/microsoft/pipelines-appservice-lib/issues/56. Instead deploy using CLI |
| 90 | + - name: Publish Website to WebApp |
| 91 | + if: false #Disable step due to comment above |
| 92 | + uses: Azure/webapps-deploy@v3 |
| 93 | + with: |
| 94 | + type: ZIP |
| 95 | + app-name: ${{ env.WEBAPP-NAME }} |
| 96 | + package: .net-app/app.zip |
99 | 97 |
|
100 | | - # Publish website to Azure App Service using CLI (WebApp) |
101 | | - - name: Publish Website to WebApp |
102 | | - uses: Azure/cli@v2 |
103 | | - with: |
104 | | - inlineScript: | |
105 | | - az webapp deploy --name ${{ env.WEBAPP-NAME }} --resource-group ${{ env.RESOURCE-GROUP }} --src-path .net-app/app.zip --type zip |
| 98 | + # Publish website to Azure App Service using CLI (WebApp) |
| 99 | + - name: Publish Website to WebApp |
| 100 | + uses: Azure/cli@v2 |
| 101 | + with: |
| 102 | + inlineScript: | |
| 103 | + az webapp deploy --name ${{ env.WEBAPP-NAME }} --resource-group ${{ env.RESOURCE-GROUP }} --src-path .net-app/app.zip --type zip |
0 commit comments