|
| 1 | +# This workflow uses actions that are not certified by GitHub. |
| 2 | +# They are provided by a third-party and are governed by |
| 3 | +# separate terms of service, privacy policy, and support |
| 4 | +# documentation. |
| 5 | + |
| 6 | +# This workflow helps you trigger a SonarQube analysis of your code and populates |
| 7 | +# GitHub Code Scanning alerts with the vulnerabilities found. |
| 8 | +# (this feature is available starting from SonarQube 9.7, Developer Edition and above) |
| 9 | + |
| 10 | +# 1. Make sure you add a valid GitHub configuration to your SonarQube (Administration > DevOps platforms > GitHub) |
| 11 | + |
| 12 | +# 2. Import your project on SonarQube |
| 13 | +# * Add your repository as a new project by clicking "Create project" from your homepage. |
| 14 | +# |
| 15 | +# 3. Select GitHub Actions as your CI and follow the tutorial |
| 16 | +# * a. Generate a new token and add it to your GitHub repository's secrets using the name SONAR_TOKEN |
| 17 | +# (On SonarQube, click on your avatar on top-right > My account > Security or ask your administrator) |
| 18 | +# |
| 19 | +# * b. Copy/paste your SonarQube host URL to your GitHub repository's secrets using the name SONAR_HOST_URL |
| 20 | +# |
| 21 | +# * c. Copy/paste the project Key into the args parameter below |
| 22 | +# (You'll find this information in SonarQube by following the tutorial or by clicking on Project Information at the top-right of your project's homepage) |
| 23 | + |
| 24 | +# Feel free to take a look at our documentation (https://docs.sonarqube.org/latest/analysis/github-integration/) |
| 25 | +# or reach out to our community forum if you need some help (https://community.sonarsource.com/c/sq/10) |
| 26 | + |
| 27 | +name: SonarQube analysis |
| 28 | + |
| 29 | +on: |
| 30 | + push: |
| 31 | + branches: [ "develop" ] |
| 32 | + pull_request: |
| 33 | + branches: [ "develop" ] |
| 34 | + workflow_dispatch: |
| 35 | + |
| 36 | +permissions: |
| 37 | + pull-requests: read # allows SonarQube to decorate PRs with analysis results |
| 38 | + |
| 39 | +jobs: |
| 40 | + Analysis: |
| 41 | + runs-on: ubuntu-latest |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: Analyze with SonarQube |
| 45 | + |
| 46 | + # You can pin the exact commit or the version. |
| 47 | + # uses: SonarSource/sonarqube-scan-action@v1.1.0 |
| 48 | + uses: SonarSource/sonarqube-scan-action@7295e71c9583053f5bf40e9d4068a0c974603ec8 |
| 49 | + env: |
| 50 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information |
| 51 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on SonarQube, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret) |
| 52 | + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} # add the URL of your instance to the secrets of this repo with the name SONAR_HOST_URL (Settings > Secrets > Actions > add new repository secret) |
| 53 | + with: |
| 54 | + # Additional arguments for the sonarcloud scanner |
| 55 | + args: |
| 56 | + # Unique key of your project. You can find it in SonarQube > [my project] > Project Information (top-right menu) |
| 57 | + # mandatory |
| 58 | + -Dsonar.projectKey= |
| 59 | + # Comma-separated paths to directories containing main source files. |
| 60 | + #-Dsonar.sources= # optional, default is project base directory |
| 61 | + # When you need the analysis to take place in a directory other than the one from which it was launched |
| 62 | + #-Dsonar.projectBaseDir= # optional, default is . |
| 63 | + # Comma-separated paths to directories containing test source files. |
| 64 | + #-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/ |
| 65 | + # 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. |
| 66 | + #-Dsonar.verbose= # optional, default is false |
0 commit comments