diff --git a/action.yaml b/action.yaml new file mode 100644 index 0000000..12ab11d --- /dev/null +++ b/action.yaml @@ -0,0 +1,23 @@ +name: 'SonarQube Scan' +description: 'Scan your code with SonarQube Scanner to detect bugs, vulnerabilities and code smells in more than 25 programming languages.' +author: 'Dwi Siswanto' +branding: + icon: 'check' + color: 'green' +runs: + using: 'docker' + image: 'Dockerfile' +inputs: + host: + description: 'SonarQube server URL' + required: true + projectBaseDir: + description: 'Set the sonar.projectBaseDir analysis property' + required: false + default: '.' + login: + description: 'Login or authentication token of a SonarQube user' + required: true + password: + description: 'Password that goes with the sonar.login username. This should be left blank if an authentication token is being used.' + required: false \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..aeb6f45 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +if [[ -z "${INPUT_PASSWORD}" ]]; then + SONAR_PASSWORD="&& true" +else + SONAR_PASSWORD="${INPUT_PASSWORD}" +fi + +sonar-scanner \ + -Dsonar.host.url=${INPUT_HOST} \ + -Dsonar.projectKey=${PWD##*/} \ + -Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR} \ + -Dsonar.login=${INPUT_LOGIN} \ + -Dsonar.password=${INPUT_PASSWORD} \ + -Dsonar.sources=. \ + -Dsonar.sourceEncoding=UTF-8 \ + ${SONAR_PASSWORD} +