This reusable GitHub Actions workflow performs static code analysis using SonarQube, suitable for integration into CI pipelines to maintain code quality.
To use this workflow in another repository:
jobs:
sonar-analysis:
uses: your-org/your-repo/.github/workflows/sonar.yaml@v1
secrets:
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}| Name | Description |
|---|---|
PERSONAL_ACCESS_TOKEN |
GitHub Personal Access Token |
SONAR_HOST_URL |
The URL of your SonarQube server |
SONAR_TOKEN |
Authentication token for SonarQube |
- ✅ Validates required secrets.
- 📥 Checks out the repository.
- 🐳 Runs SonarQube scanner via Docker, passing in required environment variables.
- This workflow runs on a
self-hostedrunner. Make sure Docker is available on the runner machine. - Ensure the repository has recent commits for accurate analysis by SonarQube.
docker runis used withsonarsource/sonar-scanner-clito scan the code inside the working directory.
This workflow is released under the MIT License.