diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index c44caa10..5bd42b4a 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -10,21 +10,26 @@ jobs: build: name: Build runs-on: ubuntu-latest + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} steps: # Setup Java - uses: actions/setup-java@v2 + if: ${{ env.SONAR_TOKEN != null }} with: java-version: 17 distribution: adopt # Checkout project files - uses: actions/checkout@v2 + if: ${{ env.SONAR_TOKEN != null }} with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis # Caches - name: 'Cache: Maven' uses: actions/cache@v2 + if: ${{ env.SONAR_TOKEN != null }} with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} @@ -36,7 +41,7 @@ jobs: key: ${{ runner.os }}-sonar - name: Analyze project + if: ${{ env.SONAR_TOKEN != null }} run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=songoda_SongodaCore env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}