Skip to content

GitHub Action

SonarCloud Scan

v1.1 Latest version
Use latest version

SonarCloud Scan

Scan your code with SonarCloud to detect bugs, vulnerabilities and code smells in more than 25 programming languages


Copy and paste the following snippet into your .yml file.

- name: SonarCloud Scan
  uses: SonarSource/sonarcloud-github-action@v1.1
Learn more about this action in SonarSource/sonarcloud-github-action
Choose a version

Scan your code with SonarCloud

Using this GitHub Action, scan your code with SonarCloud to detects bugs, vulnerabilities and code smells in more than 20 programming languages!

SonarCloud is the leading product for Continuous Code Quality & Code Security online, totally free for open-source projects. It supports all major programming languages, including Java, JavaScript, TypeScript, C#, C/C++ and many more. If your code is closed source, SonarCloud also offers a paid plan to run private analyses.


  • Have an account on SonarCloud. Sign up for free now if it's not already the case!
  • The repository to analyze is set up on SonarCloud. Set it up in just one click.


Project metadata, including the location to the sources to be analyzed, must be declared in the file in the base directory:

sonar.organization=<replace with your SonarCloud organization key>
sonar.projectKey=<replace with the key generated when setting up the project on SonarCloud>

# relative paths to source directories. More details and properties are described
# in 

You can change the analysis base directory by using the optional input projectBaseDir like this:

uses: sonarsource/sonarcloud-github-action@master
  projectBaseDir: my-custom-directory

The workflow, usually declared in .github/workflows/build.yml, looks like:

on: push
name: Main Workflow
    name: SonarCloud Trigger
    runs-on: ubuntu-latest
    - uses: actions/checkout@master
    - name: SonarCloud Scan
      uses: sonarsource/sonarcloud-github-action@master
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}


  • SONAR_TOKENRequired this is the token used to authenticate access to SonarCloud. You can generate a token on your Security page in SonarCloud. You can set the SONAR_TOKEN environment variable in the "Secrets" settings page of your repository.

Example of pull request analysis

Do not use this GitHub action if you are in the following situations

  • Your code is built with Maven: run 'org.sonarsource.scanner.maven:sonar' during the build
  • Your code is built with Gradle: use the SonarQube plugin for Gradle during the build
  • You want to analyze a .NET solution: use the SonarCloud Azure DevOps Extension to analyze your code on SonarCloud with Azure Pipelines
  • You want to analyze C/C++ code: rely on our Travis-CI extension and look at our sample C/C++ project

Have question or feedback?

To provide feedback (requesting a feature or reporting a bug) please post on the SonarSource Community Forum with the tag sonarcloud.


The Dockerfile and associated scripts and documentation in this project are released under the LGPLv3 License.

Container images built with this project include third party materials.

Build Status

You can’t perform that action at this time.