diff --git a/Dockerfile b/Dockerfile index 9866fb8..8bd98e3 100644 --- a/Dockerfile +++ b/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 @@ -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"] diff --git a/README.md b/README.md index 8115215..b197534 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/action.yml b/action.yml index 24a9607..7c1c588 100644 --- a/action.yml +++ b/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: - projectBaseDir: - description: 'Set the sonar.projectBaseDir analysis property' + args: + description: Additional arguments to the sonarcloud scanner required: false - default: '.' \ No newline at end of file + projectBaseDir: + description: Set the sonar.projectBaseDir analysis property + required: false + default: . diff --git a/entrypoint.sh b/entrypoint.sh index 079cb96..7fa41cb 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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}