sonarcloud-branch.yml 1.2 KB

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