|
14 | 14 | runs-on: ubuntu-latest |
15 | 15 | if: github.event.workflow_run && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' |
16 | 16 | steps: |
17 | | - - name: echo event |
18 | | - run: cat $GITHUB_EVENT_PATH |
| 17 | + - name: 'Test for Sonar secret' |
| 18 | + env: |
| 19 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 20 | + run: | |
| 21 | + echo "SONAR_TOKEN_SET=$(test ${SONAR_TOKEN} && echo true)" >> $GITHUB_ENV |
19 | 22 | - name: Download PR number artifact |
20 | 23 | uses: dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392 |
21 | 24 | with: |
|
37 | 40 | env: |
38 | 41 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
39 | 42 | - uses: actions/checkout@v6 |
| 43 | + env: |
| 44 | + HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} |
40 | 45 | with: |
41 | 46 | repository: ${{ github.event.workflow_run.head_repository.full_name }} |
42 | | - ref: ${{ github.event.workflow_run.head_branch }} |
| 47 | + ref: ${HEAD_BRANCH} |
43 | 48 | fetch-depth: 0 |
44 | 49 | - name: Checkout base branch |
45 | 50 | env: |
|
63 | 68 | path: ~/.m2 |
64 | 69 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
65 | 70 | restore-keys: ${{ runner.os }}-m2 |
66 | | - - name: SonarCloud Scan on PR |
67 | | - 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 }} |
| 71 | + - name: Cache SonarCloud packages |
| 72 | + uses: actions/cache@v5 |
| 73 | + if: github.ref_name == 'main' || env.SONAR_TOKEN_SET == 'true' |
| 74 | + with: |
| 75 | + path: ~/.sonar/cache |
| 76 | + key: ${{ runner.os }}-sonar |
| 77 | + restore-keys: ${{ runner.os }}-sonar |
| 78 | + - name: SonarCloud scan on PR for the Proxy Runtime |
| 79 | + 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'' |
| 80 | + env: |
| 81 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 82 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + - name: SonarCloud scan on PR for the Operator |
| 84 | + 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' |
68 | 85 | env: |
69 | 86 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
70 | 87 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments