scan.yml 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. name: Scan
  2. on:
  3. push:
  4. branches:
  5. - dev
  6. pull_request:
  7. branches:
  8. - dev
  9. jobs:
  10. sonar-scan:
  11. runs-on: ubuntu-latest
  12. strategy:
  13. matrix:
  14. jdk-version:
  15. - 17
  16. steps:
  17. - name: Checkout
  18. uses: actions/checkout@v4
  19. with:
  20. fetch-depth: 0
  21. - name: Setup Java
  22. uses: actions/setup-java@v4
  23. with:
  24. distribution: "adopt"
  25. java-version: ${{ matrix.jdk-version }}
  26. cache: "maven"
  27. - name: Cache SonarCloud packages
  28. uses: actions/cache@v3
  29. with:
  30. path: ~/.sonar/cache
  31. key: ${{ runner.os }}-sonar
  32. restore-keys: ${{ runner.os }}-sonar
  33. - name: Cache Maven packages
  34. uses: actions/cache@v3
  35. with:
  36. path: ~/.m2
  37. key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
  38. restore-keys: ${{ runner.os }}-m2
  39. - name: Analyze
  40. run: |
  41. sed -i.bak '/<repositories>/,/<\/repositories>/d' pom.xml
  42. sed -i.bak '/<pluginRepositories>/,/<\/pluginRepositories>/d' pom.xml
  43. mvn -B verify -Psonar
  44. env:
  45. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
  46. SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}