Sonar Scan #1216
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sonar Scan | |
| on: | |
| workflow_run: | |
| workflows: [Build] | |
| types: [completed] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }} | |
| cancel-in-progress: true | |
| jobs: | |
| Sonar: | |
| runs-on: ubuntu-latest | |
| if: github.event.workflow_run && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' | |
| steps: | |
| - name: echo event | |
| run: cat $GITHUB_EVENT_PATH | |
| - name: Download PR number artifact | |
| uses: dawidd6/action-download-artifact@b6e2e70617bc3265edd6dab6c906732b2f1ae151 #v21 | |
| with: | |
| workflow: Build | |
| run_id: ${{ github.event.workflow_run.id }} | |
| name: PR_NUMBER | |
| - name: Read PR_NUMBER.txt | |
| id: pr_number | |
| uses: juliangruber/read-file-action@271ff311a4947af354c6abcd696a306553b9ec18 #v1 | |
| with: | |
| path: ./PR_NUMBER.txt | |
| - name: Request GitHub API for PR data | |
| uses: octokit/request-action@b66ca9cd744693e9c29b490fc08831ab66c4a970 #v2.x | |
| id: get_pr_data | |
| with: | |
| route: GET /repos/{full_name}/pulls/{number} | |
| number: ${{ steps.pr_number.outputs.content }} | |
| full_name: ${{ github.event.repository.full_name }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| repository: ${{ github.event.workflow_run.head_repository.full_name }} | |
| ref: ${{ github.event.workflow_run.head_branch }} | |
| fetch-depth: 0 | |
| # Fork PR code runs in the base repo's trusted context. We mitigate the pwn-request | |
| # risk via approval-required settings on CI runs. See https://gh.io/securely-using-pull_request_target | |
| allow-unsafe-pr-checkout: true | |
| - name: Checkout base branch | |
| run: | | |
| git remote add upstream ${{ github.event.repository.clone_url }} | |
| git fetch upstream | |
| git checkout -B ${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} upstream/${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} | |
| git checkout ${{ github.event.workflow_run.head_branch }} | |
| git clean -ffdx && git reset --hard HEAD | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 #v4.2.0 | |
| - name: Set up JDK 21 | |
| uses: ./.github/actions/common/setup-java | |
| with: | |
| javaVersion: "21" | |
| - name: Cache SonarCloud packages | |
| uses: ./.github/actions/common/cache-sonar-packages | |
| - name: SonarCloud Scan on PR | |
| run: mvn -B clean verify -Pci -DskipITs=true org.sonarsource.scanner.maven:sonar-maven-plugin:5.0.0.4389:sonar -Dsonar.projectKey=kroxylicious_kroxylicious-junit5-extension -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 }} | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |