👷 ci(build): enhance sonar project key configuration
Some checks failed
build-and-push / lint (push) Successful in 4s
build-and-push / sonar (push) Failing after 6s
build-and-push / docker (push) Has been skipped

- add SONAR_PROJECT_KEY environment variable for flexibility
- fallback to default or file-based project key if not set
This commit is contained in:
nocci 2025-12-30 12:42:36 +00:00
parent 5b1d966c6e
commit 56ca1f63d4

View file

@ -32,8 +32,13 @@ jobs:
env:
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY }}
run: |
PROJECT_KEY=$(grep -E '^sonar.projectKey=' sonar-project.properties | cut -d= -f2 | tr -d '\r')
PROJECT_KEY="${SONAR_PROJECT_KEY}"
if [ -z "$PROJECT_KEY" ] && [ -f sonar-project.properties ]; then
PROJECT_KEY=$(grep -E '^sonar.projectKey=' sonar-project.properties | cut -d= -f2 | tr -d '\r')
fi
PROJECT_KEY=${PROJECT_KEY:-free-games-claimer}
docker run --rm \
-e SONAR_HOST_URL="$SONAR_HOST_URL" \
-e SONAR_TOKEN="$SONAR_TOKEN" \