|
| 1 | +name: CI for Dev |
| 2 | + |
| 3 | +# Controls when the action will run. |
| 4 | +on: |
| 5 | + # Triggers the workflow on push events but only for the dev branch |
| 6 | + push: |
| 7 | + branches: [ test ] |
| 8 | + |
| 9 | + # Allows you to run this workflow manually from the Actions tab |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +env: |
| 13 | + AZURE_SLOT_NAME: test # The name of the target Deployment Slot |
| 14 | + AZURE_WEBAPP_NAME: m365-galleries-mcp # The name of the Web App for hosting WebAPI |
| 15 | + DOTNET_VERSION: '10.0.x' # The dot net version to use |
| 16 | + |
| 17 | +jobs: |
| 18 | + # This job builds the Web App project |
| 19 | + build-webapp: |
| 20 | + runs-on: self-hosted |
| 21 | + |
| 22 | + steps: |
| 23 | + # This step checks out the repository so that the workflow can access its contents |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + # This step sets up the .NET environment required for building the project |
| 28 | + - name: Setup .NET |
| 29 | + uses: actions/setup-dotnet@v4 |
| 30 | + with: |
| 31 | + dotnet-version: ${{env.DOTNET_VERSION}} |
| 32 | + |
| 33 | + # This step builds the Web App project using the specified .NET version |
| 34 | + - name: 'Build Web App with .NET ${{env.DOTNET_VERSION}}' |
| 35 | + run: dotnet build --configuration Release ./src/SampleGalleriesMCPServerHttp/SampleGalleriesMCPServerHttp.csproj |
| 36 | + |
| 37 | + # This step publishes the Web App project, preparing it for deployment |
| 38 | + - name: Publish Web App project |
| 39 | + run: dotnet publish -c release -r win-x64 --self-contained true -o '${{env.DOTNET_ROOT}}/webapp' ./src/SampleGalleriesMCPServerHttp/SampleGalleriesMCPServerHttp.csproj |
| 40 | + |
| 41 | + # Now upload all the artifacts for publishing |
| 42 | + - name: Upload Web App artifact for deployment job |
| 43 | + uses: actions/upload-artifact@v4 |
| 44 | + with: |
| 45 | + name: webapp-artifacts |
| 46 | + path: ${{env.DOTNET_ROOT}}/webapp |
| 47 | + |
| 48 | + # This job deploys the Web App project |
| 49 | + deploy-webapp: |
| 50 | + runs-on: self-hosted |
| 51 | + needs: build-webapp |
| 52 | + |
| 53 | + steps: |
| 54 | + # Login to Azure using the Azure CLI for deployment |
| 55 | + - name: Login via Azure CLI for deployment |
| 56 | + uses: azure/login@v2 |
| 57 | + with: |
| 58 | + auth-type: IDENTITY |
| 59 | + tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
| 60 | + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
| 61 | + enable-AzPSSession: true |
| 62 | + |
| 63 | + # Download the Web App artifact from the build job |
| 64 | + - name: Download Web App artifact from build job |
| 65 | + uses: actions/download-artifact@v4 |
| 66 | + with: |
| 67 | + name: webapp-artifacts |
| 68 | + path: '${{env.DOTNET_ROOT}}/webapp' |
| 69 | + |
| 70 | + # Deploy the Web App to the specified Azure slot |
| 71 | + - name: 'Deploy Web App to Azure Web App ${{env.AZURE_SLOT_NAME}}' |
| 72 | + uses: azure/webapps-deploy@v2 |
| 73 | + with: |
| 74 | + app-name: ${{env.AZURE_WEBAPP_NAME}} |
| 75 | + slot-name: ${{env.AZURE_SLOT_NAME}} |
| 76 | + package: '${{env.DOTNET_ROOT}}/webapp' |
0 commit comments