• Stars
    star
    571
  • Rank 75,494 (Top 2 %)
  • Language
    Shell
  • License
    GNU Lesser Genera...
  • Created almost 5 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Integrate SonarCloud code analysis to GitHub Actions

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! In case you want to analyze C and C++ code: rely on our SonarCloud Scan for C and C++ and look at our sample C and C++ project

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 and C++ and many more. If your code is closed source, SonarCloud also offers a paid plan to run private analyses.

Requirements

  • 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.

Usage

Project metadata, including the location to the sources to be analyzed, must be declared in the file sonar-project.properties 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 https://sonarcloud.io/documentation/project-administration/narrowing-the-focus/
sonar.sources=.

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

on:
  # Trigger analysis when pushing in master or pull requests, and when creating
  # a pull request.
  push:
    branches:
      - master
  pull_request:
      types: [opened, synchronize, reopened]
name: Main Workflow
jobs:
  sonarcloud:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
      with:
        # Disabling shallow clone is recommended for improving relevancy of reporting
        fetch-depth: 0
    - name: SonarCloud Scan
      uses: sonarsource/sonarcloud-github-action@master
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

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

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

In case you need to add additional analysis parameters, you can use the args option:

- name: Analyze with SonarCloud
  uses: sonarsource/sonarcloud-github-action@master
  with:
    projectBaseDir: my-custom-directory
    args: >
      -Dsonar.organization=my-organization
      -Dsonar.projectKey=my-projectkey
      -Dsonar.python.coverage.reportPaths=coverage.xml
      -Dsonar.sources=lib/
      -Dsonar.test.exclusions=tests/**
      -Dsonar.tests=tests/
      -Dsonar.verbose=true

More information about possible analysis parameters is found in the documentation at: https://docs.sonarcloud.io/advanced-setup/analysis-parameters

See also example configurations at: https://github.com/sonarsource/sonarcloud-github-action-samples/

Secrets

  • SONAR_TOKEN – Required 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.
  • GITHUB_TOKEN – Provided by Github (see Authenticating with the GITHUB_TOKEN).

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: Follow our interactive tutorial for Github Actions after importing your project directly in SonarCloud
  • You want to analyze C and C++ code: rely on our SonarCloud Scan for C and C++ and look at our sample C and 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.

License

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

More Repositories

1

sonarqube

Continuous Inspection
Java
8,163
star
2

docker-sonarqube

🐳 SonarQube in Docker
Dockerfile
1,287
star
3

eslint-plugin-sonarjs

SonarJS rules for ESLint
TypeScript
1,148
star
4

sonar-java

β˜• SonarSource Static Analyzer for Java Code Quality and Security
Java
1,042
star
5

SonarJS

SonarSource Static Analyzer for JavaScript and TypeScript
TypeScript
958
star
6

sonar-scanning-examples

Shows how to use the Scanners
COBOL
809
star
7

SonarTS

Static code analyzer for TypeScript
Shell
763
star
8

sonar-dotnet

Code analyzer for C# and VB.NET projects https://redirect.sonarsource.com/plugins/vbnet.html
C#
664
star
9

sonarlint-intellij

SonarLint for IntelliJ
Java
553
star
10

sonarlint-vscode

SonarLint for Visual Studio Code
CSS
498
star
11

sonarlint-visualstudio

SonarLint extension for VisualStudio
C#
426
star
12

sonar-php

🐘 SonarPHP: PHP static analyzer for SonarQube & SonarLint
Java
360
star
13

sonar-scanner-msbuild

SonarScanner for .NET
C#
335
star
14

sonar-scanner-cli

Scanner CLI for SonarQube and SonarCloud
Java
331
star
15

sonarlint-eclipse

SonarLint for Eclipse
Java
256
star
16

sonar-custom-rules-examples

Shows how to bootstrap a project to write custom rules for PHP, Python, Cobol, RPG
Java
217
star
17

sonar-python

🐍 SonarQube Python plugin
Java
214
star
18

sonarlint-core

Core library to run SonarLint analysis
Java
210
star
19

sonar-scanner-cli-docker

Docker image for SonarScanner CLI
Shell
182
star
20

sonar-scanner-jenkins

SonarQube Scanner for Jenkins
Java
173
star
21

sonarqube-scan-action

Shell
165
star
22

sonar-scanner-gradle

SonarQube Scanner for Gradle
Java
162
star
23

sonar-scanner-maven

SonarQube Scanner for Maven
Java
135
star
24

sonar-custom-plugin-example

Shows how to write a SonarQube plugin
JavaScript
121
star
25

sonar-go

SonarGo: Go Analyzer for SonarQube
Java
119
star
26

sonar-scanner-commons

Common Java library used by many SonarScanners
Java
107
star
27

sonar-kotlin

SonarSource Static Analyzer for Kotlin Code Quality and Security
Kotlin
93
star
28

sonar-scanner-vsts

SonarQube TFS/VSTS Marketplace Extension
TypeScript
91
star
29

slang

Java
86
star
30

sonarqube-roslyn-sdk

SDK for SonarQube Roslyn Analyzer Plugins
C#
77
star
31

sonarlint-cli

SonarLint for CLI
Java
74
star
32

sonar-github

SonarQube GitHub Plugin (deprecated)
Java
72
star
33

sslr

SonarSource Language Recognizer
Java
71
star
34

sonarlint-language-server

Language Server for SonarLint VSCode
Java
69
star
35

sonarqube-quality-gate-action

Shell
61
star
36

sonar-.net-documentation

Documentation targeting the .Net community explaining how to install and use SonarQube to analyse .Net projects
50
star
37

sonar-html

Static analyzer for HTML used in Sonar ecosystem
Java
47
star
38

mysql-migrator

Command line tool to migrate MySQL database of SonarQube 6.7-7.8 to non-MySQL
Java
38
star
39

sonar-training-examples

Java
38
star
40

local-travis

🐳 Run travis builds on a developer workstation
Shell
37
star
41

sonar-jacoco

SonarQube JaCoCo Plugin
Java
36
star
42

sonar-loc-count

PowerShell
35
star
43

sonar-developer-toolset

Developer Toolset for Sonar-* Projects
Shell
35
star
44

rspec

Rule Specification
TypeScript
34
star
45

argument-injection-vectors

A curated list of argument injection vectors
HTML
32
star
46

sonar-ldap

🏬 LDAP Plugin for SonarQube
Java
31
star
47

sonar-xml

Java
30
star
48

SonarTS-example

TypeScript
27
star
49

sq-com_example_standard-sqscanner-travis

Standard SQ-Scanner-based project analyzed on SonarCloud using Travis
PHP
26
star
50

sonar-update-center-properties

Shell
25
star
51

sonar-auth-bitbucket

Bitbucket Authentication for SonarQube
Java
24
star
52

sonar-css

SonarCSS: CSS Analyzer for SonarQube
Java
23
star
53

sonar-analyzer-commons

Logic useful for a language plugin
Java
22
star
54

ebcdic-to-ascii-converter

Java
21
star
55

sonarlint-atom

SonarLint for Atom.io
JavaScript
20
star
56

sonar-auth-github

GitHub Authentication for SonarQube
Java
18
star
57

sonar-plugin-api

API to develop plugins for SonarQube, SonarCloud and SonarLint
Java
18
star
58

sonar-iac

Static Code Analyser for Infrastructure-as-Code languages such as CloudFormation and Terraform as well as DevOps like Docker and Kubernetes
Java
17
star
59

sq-com_example_java-maven-travis

Java Maven-based project analyzed on SonarCloud using Travis
Java
17
star
60

sonar-classloader

Toolbox for Java classloaders
Java
15
star
61

sonar-scm-git

Java
14
star
62

sonar-scanner-ant

SonarQube Scanner for Ant
Java
14
star
63

eslint-config-sonarqube

ESLint configuration for SonarQube and its plugins.
JavaScript
13
star
64

sq-com_example_c-sqscanner-travis

C SQ-Scanner-based project analyzed on SonarCloud using Travis
C
12
star
65

sonar-flex

ActionScript
12
star
66

sonarqube-webclient-dotnet

C#
11
star
67

sonarcloud-github-action-samples

Sample projects for the configuration of SonarCloud on GitHub Actions
11
star
68

sonar-scm-svn

SonarQube Plugin for SVN
Java
9
star
69

sonarcloud-circleci-orb

Support of SonarScanner CLI in CircleCI
9
star
70

orchestrator

Java library for running SonarQube in tests
Java
9
star
71

sonarcloud_examples

Listing of example projects analyzed on SonarCloud
8
star
72

sonar-update-center

Java
7
star
73

sonar-dev-maven-plugin

DEPRECATED - Maven plugin to deploy a plugin to a local SonarQube installation
Java
7
star
74

travis-utils

Toolset for SonarSource jobs on Travis
Shell
7
star
75

sslr-squid-bridge

Java
7
star
76

sonarcloud_example_go-sqscanner-travis

Go project analyzed on SonarCloud using Travis
Go
7
star
77

sonarjs-cli

[ ⛔️DEPRECATED] CLI for SonarJS
Java
7
star
78

sq-com_example_java-gradle-travis

Java Gradle-based project analyzed on SonarCloud using Travis
Java
6
star
79

pycon-sonar-workshop

PyCon US Sonar Workshop
Python
6
star
80

parent-oss

Parent file of public Maven projects
Shell
6
star
81

sonar-text

sonar-text
Java
6
star
82

sonar-ui-common

Common UI lib for SonarQube and SonarCloud
TypeScript
5
star
83

sonar-auth-saml

SAML 2.0 Authentication for SonarQube
Java
5
star
84

websites

Deprecated - customers page of old wordpress website
HTML
5
star
85

python-test-sources

Python
5
star
86

sonarcloud_example_cpp-cmake-linux-travis

C++
5
star
87

sync-jira-github-action

Change status of JIRA tickets when opening and merging pull requests
JavaScript
5
star
88

sonar-dummy-oss

Java
4
star
89

git-files-blame

A git command implemented with JGit that blames multiple files simultaneously
Java
4
star
90

sonarlint-website

HTML
4
star
91

sonarcloud-github-c-cpp

Integrate SonarCloud code analysis to GitHub Actions when build wrapper or relative paths support is required. Use https://github.com/SonarSource/sonarcloud-github-action otherwise
Shell
4
star
92

php-test-sources

PHP
3
star
93

public-git-sync

Private to public Git repository synchronization
Shell
3
star
94

sonarlint-omnisharp

Java
3
star
95

javascript-test-sources

Used for https://github.com/SonarSource/SonarJS ruling
JavaScript
3
star
96

chocolatey-packages

PowerShell
3
star
97

jsts-test-sources

TypeScript
3
star
98

license-headers

Source file headers of SonarSource projects
Shell
3
star
99

echoes-react

A React implementation of Echoes, Sonar's design system.
TypeScript
3
star
100

jfrog-setup-wrapper

Ease the usage of jfrog/jfrog-setup within Sonar
2
star