Skip to content

Commit f4c6e4d

Browse files
authored
Add args option to action (#9)
1 parent c356546 commit f4c6e4d

File tree

4 files changed

+43
-19
lines changed

4 files changed

+43
-19
lines changed

Dockerfile

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
FROM sonarsource/sonar-scanner-cli:4.3
22

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

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

22+
# Prepare entrypoint
2223
COPY entrypoint.sh /entrypoint.sh
2324
RUN chmod +x /entrypoint.sh
2425
ENTRYPOINT ["/entrypoint.sh"]

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,26 @@ with:
5959
projectBaseDir: my-custom-directory
6060
```
6161

62+
In case you need to add additional analysis parameters, you can use the `args` option:
63+
64+
```yaml
65+
- name: Analyze with SonarCloud
66+
uses: sonarsource/sonarcloud-github-action@master
67+
with:
68+
projectBaseDir: my-custom-directory
69+
args: >
70+
-Dsonar.organization=my-organization
71+
-Dsonar.projectKey=my-projectkey
72+
-Dsonar.python.coverage.reportPaths=coverage.xml
73+
-Dsonar.sources=lib/
74+
-Dsonar.test.exclusions=tests/**
75+
-Dsonar.tests=tests/
76+
-Dsonar.verbose=true
77+
```
78+
79+
More information about possible analysis parameters is found in the documentation at:
80+
https://sonarcloud.io/documentation/analysis/analysis-parameters/
81+
6282
### Secrets
6383

6484
- `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.

action.yml

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
name: 'SonarCloud Scan'
2-
description: 'Scan your code with SonarCloud to detect bugs, vulnerabilities and code smells in more than 25 programming languages.'
1+
name: SonarCloud Scan
2+
description: >
3+
Scan your code with SonarCloud to detect bugs, vulnerabilities and code smells
4+
in more than 25 programming languages.
35
branding:
4-
icon: 'check'
5-
color: 'green'
6+
icon: check
7+
color: green
68
runs:
7-
using: 'docker'
8-
image: 'Dockerfile'
9+
using: docker
10+
image: Dockerfile
911
inputs:
12+
args:
13+
description: Additional arguments to the sonarcloud scanner
14+
required: false
1015
projectBaseDir:
11-
description: 'Set the sonar.projectBaseDir analysis property'
16+
description: Set the sonar.projectBaseDir analysis property
1217
required: false
13-
default: '.'
18+
default: .

entrypoint.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,4 @@ if [[ -z "${SONARCLOUD_URL}" ]]; then
2121
SONARCLOUD_URL="https://sonarcloud.io"
2222
fi
2323

24-
sonar-scanner -Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR} -Dsonar.host.url=${SONARCLOUD_URL}
25-
26-
24+
sonar-scanner -Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR} -Dsonar.host.url=${SONARCLOUD_URL} ${INPUT_ARGS}

0 commit comments

Comments
 (0)