2022-03-01 16:39:07 +01:00
# This workflow helps you trigger a SonarCloud analysis of your code and populates GitHub Code Scanning alerts with the vulnerabilities found.
2022-03-01 16:29:12 +01:00
# 1. Login to SonarCloud.io using your GitHub account
2022-03-01 16:36:37 +01:00
2022-03-01 16:29:12 +01:00
# 2. Import your project on SonarCloud
# * Add your GitHub organization first, then add your repository as a new project.
2022-03-10 09:41:26 +01:00
# * Please note that many languages are eligible for automatic analysis, which means that the analysis will start automatically without the need to set up GitHub Actions.
2022-03-01 16:29:12 +01:00
# * This behavior can be changed in Administration > Analysis Method.
#
2022-03-10 09:41:26 +01:00
# 3. Follow the SonarCloud's online tutorial
# * a. Copy/paste the Projet Key and the Organization Key in the args parameter below
# (You'll find those info on SonarCloud. Click on "Information" at the bottom left)
#
# * b. Generate a new token and add it to your Github's repository Secrets with the name SONAR_TOKEN
# (On SonarCloud, click on your avatar on top-right > My account > Security)
2022-03-01 16:29:12 +01:00
# Feel free to take a look at our documentation (https://docs.sonarcloud.io/getting-started/github/)
# or reach out to our community forum if you need some help (https://community.sonarsource.com/c/help/sc/9)
2022-03-01 14:58:57 +01:00
name : SonarCloud analysis
on :
push :
2022-03-01 16:36:07 +01:00
branches : [ $default-branch, $protected-branches ]
2022-03-01 14:58:57 +01:00
pull_request :
2022-03-01 16:36:07 +01:00
branches : [ $default-branch ]
2022-03-01 14:58:57 +01:00
workflow_dispatch :
jobs :
Analysis :
runs-on : ubuntu-latest
2022-03-01 16:29:42 +01:00
2022-03-01 14:58:57 +01:00
steps :
2022-03-01 16:29:12 +01:00
- name : Analyze with SonarCloud
2022-03-01 14:58:57 +01:00
# You may pin to the exact commit or the version.
# uses: SonarSource/sonarcloud-github-action@de2e56b42aa84d0b1c5b622644ac17e505c9a049
uses : SonarSource/sonarcloud-github-action@v1.6
env :
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
with :
# Additional arguments to the sonarcloud scanner
2022-03-01 16:29:12 +01:00
args :
2022-03-01 14:58:57 +01:00
# Unique key of your project. You can find it in SonarCloud > Information (bottom-left menu)
-Dsonar.projectKey= # mandatory
# Unique organisation key of your project. You can find it in SonarCloud > Information (bottom-left menu)
-Dsonar.organization= # mandatory
# Comma-separated paths to directories containing main source files.
-Dsonar.sources= # optional, default is project base directory
2022-03-01 16:29:12 +01:00
# When you need the analysis to take place in a directory other than the one from which it was launched
-Dsonar.projectBaseDir= # optional, default is .
2022-03-01 14:58:57 +01:00
# Comma-separated paths to directories containing test source files.
-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/
# Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing.
-Dsonar.verbose= # optional, default is false