mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 10:35:18 +01:00
GitHub-Actions: Only run SonarCloud when token is set
Pull Requests often don't have the token (e.g. somebody outside of Songoda created it)
This commit is contained in:
parent
b375c6b2be
commit
6cd6506142
7
.github/workflows/sonarcloud.yml
vendored
7
.github/workflows/sonarcloud.yml
vendored
@ -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 }}
|
||||
|
Loading…
Reference in New Issue
Block a user