Step 3: Set Up GitHub ActionsNext, we will create a GitHub Actions workflow to integrate SonarQube scans into our CI/CD pipeline.
3.1 Set Up GitHub SecretsIn your GitHub repository, go to
Settings >
Secrets >
Actions.
- Add new secrets named SONAR_TOKEN and SONAR_HOST_URL.
- SONAR_TOKEN: Paste the project token you generated earlier.
- SONAR_HOST_URL: Paste your SonarQube public URL (e.g., http://<your-server-ip>:9000).
3.2 Create a Workflow FileIn your GitHub repository, create a new file in the .github/workflows directory (e.g., sonarqube.yml). Use the following YAML configuration as an example for Node.js projects: