Skip to content

Commit

Permalink
Add args option to action (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
dagwieers committed Aug 25, 2020
1 parent c356546 commit f4c6e4d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 19 deletions.
17 changes: 9 additions & 8 deletions Dockerfile
@@ -1,13 +1,13 @@
FROM sonarsource/sonar-scanner-cli:4.3

LABEL version="0.0.1"
LABEL repository="https://github.com/sonarsource/sonarcloud-github-action"
LABEL homepage="https://github.com/sonarsource/sonarcloud-github-action"
LABEL maintainer="SonarSource"
LABEL "com.github.actions.name"="SonarCloud Scan"
LABEL "com.github.actions.description"="Scan your code with SonarCloud to detect bugs, vulnerabilities and code smells in more than 25 programming languages."
LABEL "com.github.actions.icon"="check"
LABEL "com.github.actions.color"="green"
LABEL version="0.0.1" \
repository="https://github.com/sonarsource/sonarcloud-github-action" \
homepage="https://github.com/sonarsource/sonarcloud-github-action" \
maintainer="SonarSource" \
com.github.actions.name="SonarCloud Scan" \
com.github.actions.description="Scan your code with SonarCloud to detect bugs, vulnerabilities and code smells in more than 25 programming languages." \
com.github.actions.icon="check" \
com.github.actions.color="green"

ARG SONAR_SCANNER_HOME=/opt/sonar-scanner
ARG NODEJS_HOME=/opt/nodejs
Expand All @@ -19,6 +19,7 @@ WORKDIR /opt
# https://help.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#user
USER root

# Prepare entrypoint
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
20 changes: 20 additions & 0 deletions README.md
Expand Up @@ -59,6 +59,26 @@ with:
projectBaseDir: my-custom-directory
```

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

```yaml
- 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://sonarcloud.io/documentation/analysis/analysis-parameters/

### 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](https://sonarcloud.io/account/security/). You can set the `SONAR_TOKEN` environment variable in the "Secrets" settings page of your repository.
Expand Down
21 changes: 13 additions & 8 deletions action.yml
@@ -1,13 +1,18 @@
name: 'SonarCloud Scan'
description: 'Scan your code with SonarCloud to detect bugs, vulnerabilities and code smells in more than 25 programming languages.'
name: SonarCloud Scan
description: >
Scan your code with SonarCloud to detect bugs, vulnerabilities and code smells
in more than 25 programming languages.
branding:
icon: 'check'
color: 'green'
icon: check
color: green
runs:
using: 'docker'
image: 'Dockerfile'
using: docker
image: Dockerfile
inputs:
args:
description: Additional arguments to the sonarcloud scanner
required: false
projectBaseDir:
description: 'Set the sonar.projectBaseDir analysis property'
description: Set the sonar.projectBaseDir analysis property
required: false
default: '.'
default: .
4 changes: 1 addition & 3 deletions entrypoint.sh
Expand Up @@ -21,6 +21,4 @@ if [[ -z "${SONARCLOUD_URL}" ]]; then
SONARCLOUD_URL="https://sonarcloud.io"
fi

sonar-scanner -Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR} -Dsonar.host.url=${SONARCLOUD_URL}


sonar-scanner -Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR} -Dsonar.host.url=${SONARCLOUD_URL} ${INPUT_ARGS}

0 comments on commit f4c6e4d

Please sign in to comment.