diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 0000000..bf8bb3d --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,46 @@ +name: SonarCloud Analysis + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build-and-analyze: + name: Build and Analyze on SonarCloud + runs-on: ubuntu-latest + + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + + - name: Install SonarScanner + run: dotnet tool install --global dotnet-sonarscanner + + - name: Restore dependencies + run: dotnet restore src/Faura.sln + + - name: Begin SonarCloud Analysis + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + dotnet sonarscanner begin \ + /k:"JosepFe_faura" \ + /o:"josepfe" \ + /d:sonar.login="${SONAR_TOKEN}" \ + /d:sonar.host.url="https://sonarcloud.io" + + - name: Build solution + run: dotnet build src/Faura.sln --no-restore --no-incremental + + - name: End SonarCloud Analysis + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: dotnet sonarscanner end /d:sonar.login="${SONAR_TOKEN}"