| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- name: SonarCloud Scan (triggered by maven.yml)
- on:
- workflow_run:
- workflows:
- - Build
- types:
- - completed
- # Allows you to run this workflow manually from the Actions tab
- workflow_dispatch:
- jobs:
- sonar:
- name: SonarCloud Scan
- runs-on: ubuntu-latest
- if: ${{ github.actor != 'dependabot[bot]' && github.event.workflow_run.conclusion == 'success' }}
- steps:
- - uses: actions/checkout@v3
- with:
- repository: ${{ github.event.workflow_run.head_repository.full_name }}
- ref: ${{ github.event.workflow_run.head_branch }}
- fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- - name: Set up JDK
- uses: actions/setup-java@v3
- with:
- distribution: 'temurin'
- java-version: 17
- - name: Cache SonarCloud packages
- uses: actions/cache@v3
- with:
- path: ~/.sonar/cache
- key: ${{ runner.os }}-sonar
- restore-keys: ${{ runner.os }}-sonar
- - name: Cache Maven packages
- uses: actions/cache@v3
- with:
- path: ~/.m2
- key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
- restore-keys: ${{ runner.os }}-m2
- - name: Build and analyze
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- run: mvn -Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} -Dsonar.pullrequest.key=${{ github.event.workflow_run.pull_requests[0] != null && github.event.workflow_run.pull_requests[0].number }} -Dsonar.pullrequest.branch=${{ github.event.workflow_run.pull_requests[0] != null && github.event.workflow_run.pull_requests[0].head.ref }} -Dsonar.pullrequest.base=${{ github.event.workflow_run.pull_requests[0] != null && github.event.workflow_run.pull_requests[0].base.ref }} -U -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
|