Skip to content

Commit 1dfcdb3

Browse files
committed
- adds a check secret step for the sonarcloud workflow to avoid failures on PRs
1 parent 69294af commit 1dfcdb3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,24 @@ on:
88
- feature/v2
99
pull_request:
1010
types: [opened, synchronize, reopened]
11+
12+
env:
13+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
14+
1115
jobs:
16+
checksecret:
17+
name: check if SONAR_TOKEN is set in github secrets
18+
runs-on: ubuntu-latest
19+
outputs:
20+
is_SONAR_TOKEN_set: ${{ steps.checksecret_job.outputs.is_SONAR_TOKEN_set }}
21+
steps:
22+
- name: Check whether unity activation requests should be done
23+
id: checksecret_job
24+
run: |
25+
echo "is_SONAR_TOKEN_set=${{ env.SONAR_TOKEN != '' }}" >> $GITHUB_OUTPUT
1226
build:
27+
needs: [checksecret]
28+
if: needs.checksecret.outputs.is_SONAR_TOKEN_set == 'true'
1329
name: Build
1430
runs-on: ubuntu-latest
1531
steps:
@@ -37,5 +53,4 @@ jobs:
3753
- name: Build and analyze
3854
env:
3955
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
40-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
4156
run: ./gradlew build sonarqube --info

0 commit comments

Comments
 (0)