Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

SonarCloud Scan

SonarCloud Scan #713

Workflow file for this run

name: SonarCloud Scan
on:
workflow_run:
workflows: ["Build and Test"]
types: [completed]
jobs:
Sonar:
runs-on: ubuntu-latest
if: github.event.workflow_run && github.event.workflow_run.conclusion == 'success'
steps:
- name: Set up JDK ${{ github.event.workflow_run.outputs.jdk }}
uses: actions/setup-java@v5.0.0
with:
java-version: 21
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5.0.0
- name: Checkout PR
uses: actions/checkout@v6.0.0
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-${{ github.event.workflow_run.outputs.jdk }}
restore-keys: ${{ runner.os }}-sonar-${{ github.event.workflow_run.outputs.jdk }}
- 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/download-artifact@v6.0.0
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.analysis.jdk=${{ github.event.workflow_run.outputs.jdk }} \
-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 }}