Skip to content

Commit 6e23fa0

Browse files
author
Codex CLI
committed
ci: require Sonar token from Azure Key Vault only
1 parent aa692ff commit 6e23fa0

1 file changed

Lines changed: 5 additions & 19 deletions

File tree

.github/workflows/sonarcloud.yml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,17 @@ jobs:
2727
tenant-id: ${{ vars.AZURE_TENANT_ID }}
2828
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
2929

30-
- name: Resolve SonarCloud token
30+
- name: Read SonarCloud token from Key Vault
3131
shell: bash
32-
env:
33-
FALLBACK_SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3432
run: |
35-
KV_SONAR_TOKEN="$(az keyvault secret show \
33+
SONAR_TOKEN="$(az keyvault secret show \
3634
--vault-name "${{ vars.AZURE_KEYVAULT_NAME }}" \
3735
--name "sonar-cloud-token" \
38-
--query value -o tsv 2>/dev/null || true)"
39-
40-
TOKEN_SOURCE=""
41-
if [ -n "${FALLBACK_SONAR_TOKEN:-}" ]; then
42-
SONAR_TOKEN="${FALLBACK_SONAR_TOKEN}"
43-
TOKEN_SOURCE="github-secret-fallback"
44-
elif [ -n "${KV_SONAR_TOKEN}" ]; then
45-
SONAR_TOKEN="${KV_SONAR_TOKEN}"
46-
TOKEN_SOURCE="keyvault"
47-
fi
48-
49-
if [ -z "${TOKEN_SOURCE}" ]; then
50-
echo "No valid Sonar token found in Key Vault and no fallback secret available."
36+
--query value -o tsv)"
37+
if [ -z "${SONAR_TOKEN}" ]; then
38+
echo "Key Vault secret sonar-cloud-token is empty."
5139
exit 1
5240
fi
53-
54-
echo "::notice title=Sonar token source::${TOKEN_SOURCE}"
5541
echo "::add-mask::$SONAR_TOKEN"
5642
echo "SONAR_TOKEN=$SONAR_TOKEN" >> "$GITHUB_ENV"
5743

0 commit comments

Comments
 (0)