@@ -17,53 +17,40 @@ jobs:
1717 analyze :
1818 name : SonarCloud
1919 runs-on : ubuntu-latest
20- # Skip until the SONAR_TOKEN secret is configured (e.g. on forks). Once you
21- # add the secret in repo settings, the job runs automatically.
22- if : ${{ github.repository == 'thiagoluga/NeoReports' }}
20+ # The whole job is skipped (neutral, never red) until SonarCloud is fully set up.
21+ # To activate: import the project on sonarcloud.io, add the SONAR_TOKEN secret,
22+ # then set the repository variable SONAR_ENABLED to "true"
23+ # (gh variable set SONAR_ENABLED --body true).
24+ if : ${{ vars.SONAR_ENABLED == 'true' && github.repository == 'thiagoluga/NeoReports' }}
2325 env :
2426 DOTNET_NOLOGO : true
2527 DOTNET_CLI_TELEMETRY_OPTOUT : true
2628 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
2729 steps :
28- - name : Guard — require SONAR_TOKEN
29- id : guard
30- run : |
31- if [ -z "${SONAR_TOKEN}" ]; then
32- echo "SONAR_TOKEN not set — skipping SonarCloud analysis."
33- echo "enabled=false" >> "$GITHUB_OUTPUT"
34- else
35- echo "enabled=true" >> "$GITHUB_OUTPUT"
36- fi
37-
3830 - uses : actions/checkout@v4
39- if : steps.guard.outputs.enabled == 'true'
4031 with :
4132 # Full history gives Sonar accurate new-code / blame information.
4233 fetch-depth : 0
4334
4435 - name : Setup .NET (8 + 9)
45- if : steps.guard.outputs.enabled == 'true'
4636 uses : actions/setup-dotnet@v5
4737 with :
4838 dotnet-version : |
4939 8.0.x
5040 9.0.x
5141
5242 - name : Setup Java (required by the Sonar scanner)
53- if : steps.guard.outputs.enabled == 'true'
5443 uses : actions/setup-java@v4
5544 with :
5645 distribution : temurin
5746 java-version : " 17"
5847
5948 - name : Install Sonar + coverage tools
60- if : steps.guard.outputs.enabled == 'true'
6149 run : |
6250 dotnet tool install --global dotnet-sonarscanner
6351 dotnet tool install --global dotnet-coverage
6452
6553 - name : Build, test (with coverage) and analyze
66- if : steps.guard.outputs.enabled == 'true'
6754 env :
6855 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6956 run : |
0 commit comments