I added a step to ‘prepare’ the sonar setting programmatically:
- name: Extend environment for test reports
# When updating the Go versions in the excluded matrix, update the condition below.
if: github.repository_owner == 'clumio' && matrix.os == 'ubuntu-latest' && matrix.go == '1.21'
run: |
echo "ENABLE_TEST_REPORTS=true" >> $GITHUB_ENV
echo "REPOSITORY_NAME=$(cut -d/ -f2 <<< ${GITHUB_REPOSITORY})" >> $GITHUB_ENV
if [[ ! $GITHUB_BASE_REF ]]; then
# GITHUB_BASE_REF is only set for PRs, we are on a branch.
echo "SONAR_BRANCH=${GITHUB_REF_NAME}" >> $GITHUB_ENV
fi
And instead of the args we have a a properties file that reads the environment variables:
sonar.organization = ${env.SONAR_ORGANIZATION}
sonar.projectKey = ${env.SONAR_PROJECT_KEY}
# Parameter from Branch Analysis to target the actual branch being analyzed:
sonar.branch.name = ${env.SONAR_BRANCH}
Note that we have use a matrix workflow and you only want on call of the scanner per pipeline run as they would step on each other. We pass sonar.branch.name if not on a PR because all reports are sent to the main branch when using workflow_dispatch (manual trigger).
Thanks for that reference, Stephane, the solution was to remove quotation for property values. I also picked up a couple of ideas from the source file you’ve linked.