Update formatting and integrate previous solution changes #16
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and deploy .NET Core application to Web App astar-dev | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| types: [ opened, synchronize, reopened ] | |
| push: | |
| branches: | |
| - main | |
| env: | |
| SONAR_PROJECT: astar-dev | |
| AZURE_WEBAPP_NAME: astar-dev | |
| AZURE_WEBAPP_PACKAGE_PATH: src/uis/AStar.Dev.Web/published | |
| CONFIGURATION: Release | |
| DOTNET_CORE_VERSION: 10.0.x | |
| WORKING_DIRECTORY: src/uis/AStar.Dev.Web | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| permissions: | |
| contents: read #This is required for actions/checkout | |
| steps: | |
| - name: 🛠 Install .NET 10 | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: 🛠 Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 17 | |
| distribution: 'zulu' | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
| - name: 🛠 Cache SonarQube Cloud packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~\sonar\cache | |
| key: ${{ runner.os }}-sonar | |
| restore-keys: ${{ runner.os }}-sonar | |
| - name: 🛠 Cache SonarQube Cloud scanner | |
| id: cache-sonar-scanner | |
| uses: actions/[email protected] | |
| with: | |
| path: .\.sonar\scanner | |
| key: ${{ runner.os }}-sonar-scanner | |
| restore-keys: ${{ runner.os }}-sonar-scanner | |
| - name: 🛠 Install SonarQube Cloud scanner | |
| if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' | |
| shell: powershell | |
| run: | | |
| New-Item -Path .\.sonar\scanner -ItemType Directory | |
| dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner | |
| - name: 🔍 Restore, 🛠 Build and 🧪 Test with ☁️ SonarCloud / Qube | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| shell: powershell | |
| run: | | |
| dotnet tool install --global dotnet-coverage | |
| .\.sonar\scanner\dotnet-sonarscanner begin /k:"astar-development_${{ env.SONAR_PROJECT }}" /o:"astar-development" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.scanner.scanAll=false /d:sonar.scanner.skipJreProvisioning=true | |
| dotnet build --configuration Release | |
| dotnet-coverage collect "dotnet test --filter 'FullyQualifiedName!~Tests.EndToEnd&FullyQualifiedName!~Tests.Integration'" -f xml -o 'coverage.xml' | |
| .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" | |
| - name: 🚀 Publish App | |
| if: github.ref == 'refs/heads/main' | |
| run: dotnet publish "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --output "${{ env.AZURE_WEBAPP_PACKAGE_PATH }}" | |
| - name: 🚀 Publish Artifacts | |
| if: github.ref == 'refs/heads/main' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.AZURE_WEBAPP_NAME }} | |
| path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} | |
| deploy: | |
| if: github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| needs: build | |
| permissions: | |
| id-token: write #This is required for requesting the JWT | |
| contents: read #This is required for actions/checkout | |
| steps: | |
| - name: Download artifact from build job | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ env.AZURE_WEBAPP_NAME }} | |
| - name: Login to Azure | |
| uses: azure/login@v2 | |
| with: | |
| client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_20C04AFAEEEA4035B78816EC21632AD9 }} | |
| tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_C4F84F33F466420CB3549260472B8404 }} | |
| subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_F0BC844380D54993BA20DD5F4A7ED8F1 }} | |
| - name: Deploy to Azure Web App | |
| id: deploy-to-webapp | |
| uses: azure/webapps-deploy@v3 | |
| with: | |
| app-name: ${{ env.AZURE_WEBAPP_NAME }} | |
| slot-name: 'Production' | |
| package: . | |
| - name: Set App Settings | |
| id: app-settings | |
| uses: azure/appservice-settings@v1 | |
| with: | |
| app-name: ${{ env.AZURE_WEBAPP_NAME }} | |
| mask-inputs: true | |
| app-settings-json: '[{ "test": "Hello", "value": "1", "AzureMonitor__ConnectionString": "${{ secrets.AZUREMONITOR_CONNECTIONSTRING }}", "AzureAd__ClientSecret": "${{ secrets.AZUREAD_CLIENTSECRET }}" }]' | |
| - name: Logout of Azure | |
| run: | | |
| az logout |