|
5 | 5 | branches: |
6 | 6 | - main |
7 | 7 | workflow_dispatch: |
| 8 | + inputs: |
| 9 | + deploy_net8: |
| 10 | + description: 'Deploy .NET 8 version' |
| 11 | + type: boolean |
| 12 | + default: true |
| 13 | + deploy_net10: |
| 14 | + description: 'Deploy .NET 10 version' |
| 15 | + type: boolean |
| 16 | + default: true |
8 | 17 |
|
9 | 18 | env: |
10 | | - AZURE_WEBAPP_NAME: PerfSimDotNet |
11 | | - AZURE_WEBAPP_PACKAGE_PATH: './publish' |
12 | | - DOTNET_VERSION: '10.0.x' |
| 19 | + # App Service names - update these to match your Azure resources |
| 20 | + AZURE_WEBAPP_NET8: PerfSimDotNet8 |
| 21 | + AZURE_WEBAPP_NET10: PerfSimDotNet |
13 | 22 |
|
14 | 23 | permissions: |
15 | 24 | id-token: write |
16 | 25 | contents: read |
17 | 26 |
|
18 | 27 | jobs: |
19 | | - build-and-deploy: |
| 28 | + build: |
20 | 29 | runs-on: ubuntu-latest |
| 30 | + strategy: |
| 31 | + matrix: |
| 32 | + include: |
| 33 | + - framework: net8.0 |
| 34 | + dotnet-version: '8.0.x' |
| 35 | + artifact-name: publish-net8 |
| 36 | + - framework: net10.0 |
| 37 | + dotnet-version: '10.0.x' |
| 38 | + artifact-name: publish-net10 |
21 | 39 |
|
22 | 40 | steps: |
23 | 41 | - name: Checkout code |
24 | 42 | uses: actions/checkout@v4 |
25 | 43 |
|
26 | | - - name: Setup .NET |
| 44 | + - name: Setup .NET ${{ matrix.dotnet-version }} |
27 | 45 | uses: actions/setup-dotnet@v4 |
28 | 46 | with: |
29 | | - dotnet-version: ${{ env.DOTNET_VERSION }} |
| 47 | + dotnet-version: ${{ matrix.dotnet-version }} |
30 | 48 |
|
31 | 49 | - name: Restore dependencies |
32 | 50 | run: dotnet restore src/PerfProblemSimulator/PerfProblemSimulator.csproj |
33 | 51 |
|
34 | | - - name: Build |
35 | | - run: dotnet build src/PerfProblemSimulator/PerfProblemSimulator.csproj --configuration Release --no-restore |
| 52 | + - name: Build (${{ matrix.framework }}) |
| 53 | + run: dotnet build src/PerfProblemSimulator/PerfProblemSimulator.csproj --configuration Release --framework ${{ matrix.framework }} --no-restore |
36 | 54 |
|
37 | | - - name: Publish |
38 | | - run: dotnet publish src/PerfProblemSimulator/PerfProblemSimulator.csproj --configuration Release --no-build --output ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} |
| 55 | + - name: Publish (${{ matrix.framework }}) |
| 56 | + run: dotnet publish src/PerfProblemSimulator/PerfProblemSimulator.csproj --configuration Release --framework ${{ matrix.framework }} --no-build --output ./publish |
| 57 | + |
| 58 | + - name: Upload artifact |
| 59 | + uses: actions/upload-artifact@v4 |
| 60 | + with: |
| 61 | + name: ${{ matrix.artifact-name }} |
| 62 | + path: ./publish |
| 63 | + |
| 64 | + deploy-net8: |
| 65 | + needs: build |
| 66 | + runs-on: ubuntu-latest |
| 67 | + if: github.event_name == 'push' || github.event.inputs.deploy_net8 == 'true' |
| 68 | + |
| 69 | + steps: |
| 70 | + - name: Download .NET 8 artifact |
| 71 | + uses: actions/download-artifact@v4 |
| 72 | + with: |
| 73 | + name: publish-net8 |
| 74 | + path: ./publish-net8 |
| 75 | + |
| 76 | + - name: Login to Azure |
| 77 | + uses: azure/login@v2 |
| 78 | + with: |
| 79 | + client-id: ${{ secrets.AZURE_CLIENT_ID }} |
| 80 | + tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
| 81 | + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
| 82 | + |
| 83 | + - name: Deploy to Azure Web App (.NET 8) |
| 84 | + uses: azure/webapps-deploy@v3 |
| 85 | + with: |
| 86 | + app-name: ${{ env.AZURE_WEBAPP_NET8 }} |
| 87 | + package: ./publish-net8 |
| 88 | + |
| 89 | + deploy-net10: |
| 90 | + needs: build |
| 91 | + runs-on: ubuntu-latest |
| 92 | + if: github.event_name == 'push' || github.event.inputs.deploy_net10 == 'true' |
| 93 | + |
| 94 | + steps: |
| 95 | + - name: Download .NET 10 artifact |
| 96 | + uses: actions/download-artifact@v4 |
| 97 | + with: |
| 98 | + name: publish-net10 |
| 99 | + path: ./publish-net10 |
39 | 100 |
|
40 | 101 | - name: Login to Azure |
41 | 102 | uses: azure/login@v2 |
|
44 | 105 | tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
45 | 106 | subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
46 | 107 |
|
47 | | - - name: Deploy to Azure Web App |
| 108 | + - name: Deploy to Azure Web App (.NET 10) |
48 | 109 | uses: azure/webapps-deploy@v3 |
49 | 110 | with: |
50 | | - app-name: ${{ env.AZURE_WEBAPP_NAME }} |
51 | | - package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} |
| 111 | + app-name: ${{ env.AZURE_WEBAPP_NET10 }} |
| 112 | + package: ./publish-net10 |
0 commit comments