Skip to content

Commit 403faee

Browse files
committed
Secrets are not available in if
So let's startup a job before and check it there... You know because efficient design
1 parent 4575336 commit 403faee

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

.github/workflows/sonar.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,22 @@ env:
2424
SONARCLOUD_HOST: https://sonarcloud.io
2525

2626
jobs:
27+
token-check:
28+
runs-on: ubuntu-latest
29+
outputs:
30+
hasToken: ${{ steps.check-token.outputs.has }}
31+
steps:
32+
- id: check-token
33+
run: |
34+
[ -z $SONAR_TOKEN ] && echo "has=false" || echo "has=true" >> "$GITHUB_OUTPUT"
35+
env:
36+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
37+
2738
sonar:
2839
name: SonarCloud Scan
2940
runs-on: ubuntu-latest
30-
if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'renovate/')) && secrets.SONAR_TOKEN != '' }}
41+
needs: token-check
42+
if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'renovate/')) && needs.token-check.outputs.hasToken }}
3143
steps:
3244
- uses: actions/checkout@v4
3345
with:

0 commit comments

Comments
 (0)