|
| 1 | +name: Build .NET Core application |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: [ opened, synchronize, reopened ] |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | +env: |
| 9 | + AZURE_WEBAPP_NAME: astar-dev |
| 10 | + AZURE_WEBAPP_PACKAGE_PATH: src/uis/AStar.Dev.Web/published |
| 11 | + CONFIGURATION: Release |
| 12 | + DOTNET_CORE_VERSION: 9.0.x |
| 13 | + WORKING_DIRECTORY: src/uis/AStar.Dev.Web |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: windows-latest |
| 17 | + permissions: |
| 18 | + contents: read #This is required for actions/checkout |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Set up JDK 17 |
| 22 | + uses: actions/setup-java@v4 |
| 23 | + with: |
| 24 | + java-version: 17 |
| 25 | + distribution: 'zulu' |
| 26 | + |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
| 30 | + |
| 31 | + - name: 🛠 Cache SonarQube Cloud packages |
| 32 | + uses: actions/cache@v4 |
| 33 | + with: |
| 34 | + path: ~\sonar\cache |
| 35 | + key: ${{ runner.os }}-sonar |
| 36 | + restore-keys: ${{ runner.os }}-sonar |
| 37 | + |
| 38 | + - name: 🛠 Cache SonarQube Cloud scanner |
| 39 | + id: cache-sonar-scanner |
| 40 | + uses: actions/cache@v4 |
| 41 | + with: |
| 42 | + path: .\.sonar\scanner |
| 43 | + key: ${{ runner.os }}-sonar-scanner |
| 44 | + restore-keys: ${{ runner.os }}-sonar-scanner |
| 45 | + |
| 46 | + - name: 🛠 Install SonarQube Cloud scanner |
| 47 | + if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' |
| 48 | + shell: powershell |
| 49 | + run: | |
| 50 | + New-Item -Path .\.sonar\scanner -ItemType Directory |
| 51 | + dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner |
| 52 | +
|
| 53 | + - name: 🔍 Restore, 🛠 Build and 🧪 Test with ☁️ SonarCloud / Qube |
| 54 | + env: |
| 55 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 56 | + shell: powershell |
| 57 | + run: | |
| 58 | + dotnet tool install --global dotnet-coverage |
| 59 | + .\.sonar\scanner\dotnet-sonarscanner begin /k:"astar-development_astar-dev-database-testing" /o:"astar-development" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.scanner.scanAll=false /d:sonar.scanner.skipJreProvisioning=true |
| 60 | + dotnet build |
| 61 | + dotnet-coverage collect 'dotnet test --filter "FullyQualifiedName!~Tests.EndToEnd"' -f xml -o 'coverage.xml' |
| 62 | + .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" |
| 63 | +# |
| 64 | +# - name: 🚀 Publish App |
| 65 | +# run: dotnet publish "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-build --output "${{ env.AZURE_WEBAPP_PACKAGE_PATH }}" |
| 66 | +# |
| 67 | +# - name: 🚀 Publish Artifacts |
| 68 | +# uses: actions/upload-artifact@v4 |
| 69 | +# with: |
| 70 | +# name: webapp |
| 71 | +# path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} |
| 72 | + |
| 73 | +# deploy: |
| 74 | +# runs-on: ubuntu-latest |
| 75 | +# needs: build |
| 76 | +# environment: |
| 77 | +# name: 'Production' |
| 78 | +# url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} |
| 79 | +# permissions: |
| 80 | +# id-token: write #This is required for requesting the JWT |
| 81 | +# contents: read #This is required for actions/checkout |
| 82 | +# |
| 83 | +# steps: |
| 84 | +# - name: Download artifact from build job |
| 85 | +# uses: actions/download-artifact@v4 |
| 86 | +# with: |
| 87 | +# name: webapp |
| 88 | +# path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} |
| 89 | +# |
| 90 | +# - name: Login to Azure |
| 91 | +# uses: azure/login@v2 |
| 92 | +# with: |
| 93 | +# client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_E8497C9E217E4655814D0F7761AAE04F }} |
| 94 | +# tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_085200BD39F041C4999EEB0851E8D6A2 }} |
| 95 | +# subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_3FEB324333C140D8A0FA99AC083AEB82 }} |
| 96 | +# |
| 97 | +# - name: Deploy to Azure WebApp |
| 98 | +# uses: azure/webapps-deploy@v3 |
| 99 | +# with: |
| 100 | +# app-name: ${{ env.AZURE_WEBAPP_NAME }} |
| 101 | +# package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} |
0 commit comments