sonarcloud.yml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. name: SonarCloud Scan
  2. on:
  3. push:
  4. branches: [ main, master ]
  5. pull_request:
  6. types: [opened, synchronize, reopened]
  7. # Allows you to run this workflow manually from the Actions tab
  8. workflow_dispatch:
  9. jobs:
  10. pre_job:
  11. runs-on: ubuntu-latest
  12. outputs:
  13. should_skip: ${{ steps.skip_check.outputs.should_skip }}
  14. steps:
  15. - id: skip_check
  16. uses: fkirc/skip-duplicate-actions@master
  17. with:
  18. concurrent_skipping: 'same_content_newer'
  19. skip_after_successful_duplicate: 'true'
  20. sonar:
  21. needs: pre_job
  22. name: SonarCloud Scan
  23. runs-on: ubuntu-latest
  24. if: ${{ needs.pre_job.outputs.should_skip != 'true' && github.actor != 'dependabot[bot]' }}
  25. steps:
  26. - uses: actions/checkout@v3
  27. with:
  28. fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
  29. - name: Set up JDK
  30. uses: actions/setup-java@v3
  31. with:
  32. distribution: 'temurin'
  33. java-version: 17
  34. - name: Cache SonarCloud packages
  35. uses: actions/cache@v3
  36. with:
  37. path: ~/.sonar/cache
  38. key: ${{ runner.os }}-sonar
  39. restore-keys: ${{ runner.os }}-sonar
  40. - name: Cache Maven packages
  41. uses: actions/cache@v3
  42. with:
  43. path: ~/.m2
  44. key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
  45. restore-keys: ${{ runner.os }}-m2
  46. - name: Build and analyze
  47. env:
  48. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  49. SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
  50. run: mvn -U -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar