Add support of project base dir from env

This commit is contained in:
Romain PRÉVOST 2019-10-04 16:55:48 +02:00 committed by Simon Brandhof
commit c7f7c25d41
3 changed files with 15 additions and 2 deletions

View file

@ -4,7 +4,7 @@ Using this GitHub Action, scan your code with [SonarCloud](https://sonarcloud.io
<img src="./images/SonarCloud-72px.png">
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
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.
## Requirements
@ -24,6 +24,14 @@ sonar.projectKey=<replace with the key generated when setting up the project on
sonar.sources=.
```
You can change the analysis base directory by using the optional input `projectBaseDir` like this:
```yaml
uses: sonarsource/sonarcloud-github-action@master
with:
projectBaseDir: my-custom-directory
```
The workflow, usually declared in `.github/workflows/build.yml`, looks like:
```yaml

View file

@ -6,3 +6,8 @@ branding:
runs:
using: 'docker'
image: 'Dockerfile'
inputs:
projectBaseDir:
description: 'Set the sonar.projectBaseDir analysis property'
required: false
default: '.'

View file

@ -29,6 +29,6 @@ if [[ -z "${SONARCLOUD_URL}" ]]; then
SONARCLOUD_URL="https://sonarcloud.io"
fi
sonar-scanner -Dsonar.host.url=${SONARCLOUD_URL}
sonar-scanner -Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR} -Dsonar.host.url=${SONARCLOUD_URL}