Skip to content

Commit e56e0c1

Browse files
committed
Only run sonar workflow when secret is present
Fixes xdev-software/standard-maven-template#57
1 parent 9d7d2d0 commit e56e0c1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

.github/workflows/sonar.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ jobs:
2727
sonar:
2828
name: SonarCloud Scan
2929
runs-on: ubuntu-latest
30-
# Dependabot PRs have no access to secrets (SONAR_TOKEN) -> Ignore them
31-
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'dependabot/') }}
30+
if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'renovate/')) && secrets.SONAR_TOKEN != '' }}
3231
steps:
3332
- uses: actions/checkout@v4
3433
with:
@@ -55,7 +54,11 @@ jobs:
5554
restore-keys: ${{ runner.os }}-gradle
5655

5756
- name: Build
58-
run: ./gradlew build sonarqube --info -Dsonar.projectKey=${{ env.SONARCLOUD_ORG }}_${{ github.event.repository.name }} -Dsonar.organization=${{ env.SONARCLOUD_ORG }} -Dsonar.host.url=${{ env.SONARCLOUD_HOST }}
57+
run: |
58+
./gradlew build sonarqube --info \
59+
-Dsonar.projectKey=${{ env.SONARCLOUD_ORG }}_${{ github.event.repository.name }} \
60+
-Dsonar.organization=${{ env.SONARCLOUD_ORG }} \
61+
-Dsonar.host.url=${{ env.SONARCLOUD_HOST }}
5962
env:
6063
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
6164
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

0 commit comments

Comments
 (0)