Skip to content

Commit 5f34baf

Browse files
committed
ci: scope Sonar token to scan steps after tests
1 parent 16f7290 commit 5f34baf

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

.github/workflows/sonarcloud.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ jobs:
2020
with:
2121
fetch-depth: 0
2222

23+
- uses: actions/setup-python@v6
24+
with:
25+
python-version: '3.12'
26+
27+
- name: Install dependencies
28+
run: make install-dev
29+
30+
- name: Run tests with coverage
31+
run: make coverage-sonar
32+
2333
- name: Azure login (OIDC)
2434
uses: azure/login@v2
2535
with:
@@ -28,6 +38,7 @@ jobs:
2838
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
2939

3040
- name: Read SonarCloud token from Key Vault
41+
id: sonar_token
3142
shell: bash
3243
run: |
3344
SONAR_TOKEN="$(az keyvault secret show \
@@ -39,23 +50,13 @@ jobs:
3950
exit 1
4051
fi
4152
echo "::add-mask::$SONAR_TOKEN"
42-
echo "SONAR_TOKEN=$SONAR_TOKEN" >> "$GITHUB_ENV"
43-
44-
- uses: actions/setup-python@v6
45-
with:
46-
python-version: '3.12'
47-
48-
- name: Install dependencies
49-
run: make install-dev
50-
51-
- name: Run tests with coverage
52-
run: make coverage-sonar
53+
echo "value=$SONAR_TOKEN" >> "$GITHUB_OUTPUT"
5354
5455
- name: SonarCloud scan
5556
uses: SonarSource/sonarcloud-github-action@ffc3010689be73b8e5ae0c57ce35968afd7909e8
5657
env:
5758
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58-
SONAR_TOKEN: ${{ env.SONAR_TOKEN }}
59+
SONAR_TOKEN: ${{ steps.sonar_token.outputs.value }}
5960
with:
6061
args: >
6162
-Dsonar.host.url=https://sonarcloud.io
@@ -70,6 +71,6 @@ jobs:
7071
with:
7172
scanMetadataReportFile: dist/quality/sonar/scannerwork/report-task.txt
7273
env:
73-
SONAR_TOKEN: ${{ env.SONAR_TOKEN }}
74+
SONAR_TOKEN: ${{ steps.sonar_token.outputs.value }}
7475
SONAR_HOST_URL: https://sonarcloud.io
7576
timeout-minutes: 5

0 commit comments

Comments
 (0)