SonarCloud Scan #9
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: SonarCloud Scan | |
| on: | |
| workflow_run: | |
| workflows: ["Build and Test"] | |
| type: [completed] | |
| jobs: | |
| Sonar: | |
| runs-on: ubuntu-latest | |
| if: github.event.workflow_run && github.event.workflow_run.conclusion == 'success' | |
| steps: | |
| - name: Set up JDK | |
| uses: actions/[email protected] | |
| with: | |
| java-version: 17 | |
| distribution: temurin | |
| - name: Setup Gradle | |
| uses: gradle/actions/[email protected] | |
| - name: Checkout PR | |
| uses: actions/[email protected] | |
| with: | |
| repository: ${{ github.event.workflow_run.head_repository.full_name }} | |
| ref: ${{ github.event.workflow_run.head_branch }} | |
| fetch-depth: 0 | |
| - name: Cache SonarCloud packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.sonar/cache | |
| key: ${{ runner.os }}-sonar | |
| restore-keys: ${{ runner.os }}-sonar | |
| - name: Cache Gradle packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.gradle/caches | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
| restore-keys: ${{ runner.os }}-gradle | |
| - name: Download Coverage | |
| uses: actions/[email protected] | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| run-id: ${{ github.event.workflow_run.id }} | |
| path: ./ | |
| merge-multiple: true | |
| - name: Build | |
| run: ./gradlew build | |
| - name: Analyze | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| run: | | |
| ./gradlew sonar --info -Dorg.gradle.jvmargs=-Xmx4096M \ | |
| -Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} \ | |
| -Dsonar.pullrequest.key=${{ github.event.workflow_run.pull_requests[0].number }} \ | |
| -Dsonar.pullrequest.branch=${{ github.event.workflow_run.pull_requests[0].head.ref }} \ | |
| -Dsonar.pullrequest.base=${{ github.event.workflow_run.pull_requests[0].base.ref }} |