Skip to content

Commit 7f171fa

Browse files
author
Codex CLI
committed
ci: fetch Sonar token from Azure Key Vault via OIDC
1 parent 9c072d0 commit 7f171fa

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

.github/workflows/sonarcloud.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,33 @@ on:
1010
jobs:
1111
sonarcloud:
1212
runs-on: ubuntu-latest
13+
environment: org-prod
1314
permissions:
15+
id-token: write
1416
contents: read
1517
pull-requests: write
1618
steps:
1719
- uses: actions/checkout@v6
1820
with:
1921
fetch-depth: 0
2022

23+
- name: Azure login (OIDC)
24+
uses: azure/login@v2
25+
with:
26+
client-id: ${{ vars.AZURE_CLIENT_ID }}
27+
tenant-id: ${{ vars.AZURE_TENANT_ID }}
28+
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
29+
30+
- name: Read SonarCloud token from Key Vault
31+
shell: bash
32+
run: |
33+
SONAR_TOKEN="$(az keyvault secret show \
34+
--vault-name "${{ vars.AZURE_KEYVAULT_NAME }}" \
35+
--name "sonar-cloud-token" \
36+
--query value -o tsv)"
37+
echo "::add-mask::$SONAR_TOKEN"
38+
echo "SONAR_TOKEN=$SONAR_TOKEN" >> "$GITHUB_ENV"
39+
2140
- uses: actions/setup-python@v6
2241
with:
2342
python-version: '3.12'
@@ -32,7 +51,7 @@ jobs:
3251
uses: SonarSource/sonarcloud-github-action@ffc3010689be73b8e5ae0c57ce35968afd7909e8
3352
env:
3453
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
54+
SONAR_TOKEN: ${{ env.SONAR_TOKEN }}
3655
with:
3756
args: >
3857
-Dsonar.host.url=https://sonarcloud.io
@@ -47,6 +66,6 @@ jobs:
4766
with:
4867
scanMetadataReportFile: dist/quality/sonar/scannerwork/report-task.txt
4968
env:
50-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
69+
SONAR_TOKEN: ${{ env.SONAR_TOKEN }}
5170
SONAR_HOST_URL: https://sonarcloud.io
5271
timeout-minutes: 5

0 commit comments

Comments
 (0)