diff --git a/.github/workflows/build-project.yml b/.github/workflows/build-project.yml index 6c4ac3f6..2dcf24a6 100644 --- a/.github/workflows/build-project.yml +++ b/.github/workflows/build-project.yml @@ -11,37 +11,42 @@ on: jobs: build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 6.0.x - # - name: build - # run: | - # cd source - # dotnet restore - # dotnet build - - - name: Build and analyze - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - # shell: powershell - run: | - cd source - .\.sonar\scanner\dotnet-sonarscanner begin /k:"JosepFe_devon4net" /o:"josepfe" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" - dotnet restore - dotnet build - .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" - - # - name: Analyze with SonarCloud - # uses: sonarsource/sonarcloud-github-action@v1 - # with: - # project-key: ${{ secrets.SONAR_PROJECT_KEY }} - # project-name: "devon4net" - # token: ${{ secrets.SONAR_TOKEN }} - # github-token: ${{ secrets.GITHUB_TOKEN }} + name: Build and analyze + runs-on: ubuntu-latest # Change to Ubuntu + steps: + - name: Set up JDK 17 + uses: actions/setup-java@v2 # Update to the latest version + with: + java-version: 17 + distribution: 'adopt' # Ubuntu uses AdoptOpenJDK + - uses: actions/checkout@v2 # Update to the latest version + with: + fetch-depth: 0 + - name: Cache SonarCloud packages + uses: actions/cache@v2 # Update to the latest version + with: + path: ~/.sonar/cache # Change the path to the Linux format + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache SonarCloud scanner + id: cache-sonar-scanner + uses: actions/cache@v2 # Update to the latest version + with: + path: ./.sonar/scanner + key: ${{ runner.os }}-sonar-scanner + restore-keys: ${{ runner.os }}-sonar-scanner + - name: Install SonarCloud scanner + if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' + run: | + mkdir -p .sonar/scanner + dotnet tool update dotnet-sonarscanner --tool-path .sonar/scanner + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + ./.sonar/scanner/dotnet-sonarscanner begin /k:"JosepFe_devon4net" /o:"josepfe" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" + cd source + dotnet restore + dotnet build + ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"