Skip to content

Commit a42ac9b

Browse files
committed
ci: Use DEPENDABOT_AUTH for dependabot-triggered Sonar scans
Dependabot-triggered runs read the Dependabot secret store rather than the Actions one, so `secrets.SECRET_AUTH` resolves to an empty string. The sonar-scanner action then fails to authenticate with Secret Manager and cannot load the github-token secret, surfacing as the misleading `Missing env var: GITHUB_TOKEN`. Select DEPENDABOT_AUTH only when dependabot is the actor, leaving every human-authored run on SECRET_AUTH unchanged. Evidence this is actor-scoped rather than code-scoped: on a single dependabot commit, commit-msg, pre-commit and the ASVS gate all pass and only CI fails -- it is the one workflow that reads the secret. Rebasing or recreating those PRs cannot help, since both preserve dependabot as the triggering actor.
1 parent 93c0a01 commit a42ac9b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

.github/workflows/pull_request.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,7 @@ jobs:
3131
sonar-host: https://sonarcloud.io
3232
sonar-scanner: maven
3333
main-branch: master
34-
service-account-key: ${{ secrets.SECRET_AUTH }}
34+
# Dependabot-triggered runs read the Dependabot secret store, where
35+
# SECRET_AUTH does not exist. Fall back to the Dependabot-scoped key
36+
# for those runs only.
37+
service-account-key: ${{ github.actor == 'dependabot[bot]' && secrets.DEPENDABOT_AUTH || secrets.SECRET_AUTH }}

0 commit comments

Comments
 (0)