@@ -21,17 +21,20 @@ jobs:
2121 echo "SONAR_TOKEN_SET=$(test ${SONAR_TOKEN} && echo true)" >> $GITHUB_ENV
2222 - name : Download PR number artifact
2323 uses : dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392
24+ if : env.SONAR_TOKEN_SET == 'true'
2425 with :
2526 workflow : Build
2627 run_id : ${{ github.event.workflow_run.id }}
2728 name : PR_NUMBER
2829 - name : Read PR_NUMBER.txt
2930 id : pr_number
3031 uses : juliangruber/read-file-action@b549046febe0fe86f8cb4f93c24e284433f9ab58
32+ if : env.SONAR_TOKEN_SET == 'true'
3133 with :
3234 path : ./PR_NUMBER.txt
3335 - name : Request GitHub API for PR data
3436 uses : octokit/request-action@05a2312de9f8207044c4c9e41fe19703986acc13
37+ if : env.SONAR_TOKEN_SET == 'true'
3538 id : get_pr_data
3639 with :
3740 route : GET /repos/{full_name}/pulls/{number}
@@ -40,11 +43,15 @@ jobs:
4043 env :
4144 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4245 - uses : actions/checkout@v6
46+ if : env.SONAR_TOKEN_SET == 'true'
4347 with :
4448 repository : ${{ github.event.workflow_run.head_repository.full_name }}
45- ref : ${{ github.event.workflow_run.head_branch }}
49+ ref : $HEAD_REF
4650 fetch-depth : 0
51+ env :
52+ HEAD_REF : ${{ github.event.workflow_run.head_branch }}
4753 - name : Checkout base branch
54+ if : env.SONAR_TOKEN_SET == 'true'
4855 env :
4956 HEAD_BRANCH : ${{ github.event.workflow_run.head_branch }}
5057 run : |
@@ -55,31 +62,36 @@ jobs:
5562 git clean -ffdx && git reset --hard HEAD
5663 - name : Set up QEMU
5764 uses : docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130
65+ if : env.SONAR_TOKEN_SET == 'true'
5866 - name : Set up JDK 21
5967 uses : actions/setup-java@v5
68+ if : env.SONAR_TOKEN_SET == 'true'
6069 with :
6170 java-version : 21
6271 distribution : ' temurin'
6372 - name : ' Cache Maven packages'
6473 uses : actions/cache/restore@v5
74+ if : env.SONAR_TOKEN_SET == 'true'
6575 with :
6676 path : ~/.m2
6777 key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
6878 restore-keys : ${{ runner.os }}-m2
6979 - name : Cache SonarCloud packages
7080 uses : actions/cache@v5
71- if : github.ref_name == 'main' || env.SONAR_TOKEN_SET == 'true'
81+ if : env.SONAR_TOKEN_SET == 'true'
7282 with :
7383 path : ~/.sonar/cache
7484 key : ${{ runner.os }}-sonar
7585 restore-keys : ${{ runner.os }}-sonar
7686 - name : SonarCloud scan on PR for the Proxy Runtime
77- run : mvn -B clean verify -Pci -DskipITs=true org.sonarsource.scanner.maven:sonar-maven-plugin:5.5.0.6356:sonar -Djapicmp.skip=true -Dsonar.projectKey=kroxylicious_kroxylicious -Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} -Dsonar.pullrequest.key=${{ fromJson(steps.get_pr_data.outputs.data).number }} -Dsonar.pullrequest.branch=${{ fromJson(steps.get_pr_data.outputs.data).head.ref }} -Dsonar.pullrequest.base=${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} -pl ''!:kroxylicious-operator''
87+ if : env.SONAR_TOKEN_SET == 'true'
88+ run : mvn -B clean verify -Pci -DskipITs=true org.sonarsource.scanner.maven:sonar-maven-plugin:5.5.0.6356:sonar -Djapicmp.skip=true -Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} -Dsonar.pullrequest.key=${{ fromJson(steps.get_pr_data.outputs.data).number }} -Dsonar.pullrequest.branch=${{ fromJson(steps.get_pr_data.outputs.data).head.ref }} -Dsonar.pullrequest.base=${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} -pl ''!:kroxylicious-operator''
7889 env :
7990 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
8091 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
8192 - name : SonarCloud scan on PR for the Operator
82- run : mvn -B clean verify -Pci -DskipITs=true org.sonarsource.scanner.maven:sonar-maven-plugin:5.5.0.6356:sonar -Djapicmp.skip=true -Dsonar.projectKey=kroxylicious_operator -Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} -Dsonar.pullrequest.key=${{ fromJson(steps.get_pr_data.outputs.data).number }} -Dsonar.pullrequest.branch=${{ fromJson(steps.get_pr_data.outputs.data).head.ref }} -Dsonar.pullrequest.base=${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} -pl ':kroxylicious-operator,:kroxylicious-parent'
93+ if : env.SONAR_TOKEN_SET == 'true'
94+ run : mvn -B clean verify -Pci -DskipITs=true org.sonarsource.scanner.maven:sonar-maven-plugin:5.5.0.6356:sonar -Djapicmp.skip=true -Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} -Dsonar.pullrequest.key=${{ fromJson(steps.get_pr_data.outputs.data).number }} -Dsonar.pullrequest.branch=${{ fromJson(steps.get_pr_data.outputs.data).head.ref }} -Dsonar.pullrequest.base=${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} -pl ':kroxylicious-operator,:kroxylicious-parent'
8395 env :
8496 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
8597 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments