Analyze Your Repository With GitHub Actions

To configure analysis of your project using GitHub Actions you should follow the in-product tutorial. Under the Configure tab of your project homepage in SonarCloud, simply click on With GitHub Actions. You can also access the tutorials by going to Administration > Analysis Method.

The tutorial will walk you through the precise steps to set up the analysis but the basic steps are these:

  1. Define the SONAR_TOKEN environment variable in your repository by setting up a GitHub Secret. The SONAR_TOKEN identifies and authenticates you to SonarCloud. The tutorial will provide the precise value for your specific account.
  2. Set the essential analysis parameters, sonar.projectKeysonar.organization, and The tutorial will be populated with the correct values for your specific account. These parameters are set differently depending on your project type:
    • In the pom.xml for Java Maven projects.
    • In the build.gradle file for Java Gradle projects.
    • In the SonarScanner command line for .NET projects.
    • In the file for other types of projects. You can also add additional analysis parameters to further specify your analysis details (See Analysis Parameters).
  3. Create the .github/workflows/build.yml file that defines the steps of your build. In addition to the usual steps that build your project, you need to invoke the SonarScanner to perform the analysis of your code. This is done differently depending on your project type:
    • A Maven plugin for Java Maven projects.
    • A Gradle plugin for Java Gradle projects.
    • A dedicated .NET scanner for .NET projects.
    • The SonarCloud GitHub Action for other projects. The tutorial will provide the specific details for your project type.

© 2008-2022, SonarCloud by SonarSource SA. All rights reserved.