From bb543d0f7a0cf6f688c387dab8e51993436296a8 Mon Sep 17 00:00:00 2001 From: dw1 Date: Tue, 23 Jun 2020 05:59:03 +0700 Subject: [PATCH] :beetle: Add dynamic projectKey input. Fixes #5 --- action.yaml | 30 +++++++++++++++++------------- entrypoint.sh | 3 ++- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/action.yaml b/action.yaml index 12ab11d..411651c 100644 --- a/action.yaml +++ b/action.yaml @@ -1,23 +1,27 @@ -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' +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' + icon: "check" + color: "green" runs: - using: 'docker' - image: 'Dockerfile' + using: "docker" + image: "Dockerfile" inputs: host: - description: 'SonarQube server URL' + description: "SonarQube server URL" required: true - projectBaseDir: - description: 'Set the sonar.projectBaseDir analysis property' + projectKey: + description: "The project's unique key. Allowed characters are: letters, numbers, -, _, . and :, with at least one non-digit." required: false - default: '.' + default: "" + projectBaseDir: + description: "Set the sonar.projectBaseDir analysis property" + required: false + default: "." login: - description: 'Login or authentication token of a SonarQube user' + 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.' + 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 index 5e2d248..5977021 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -11,10 +11,11 @@ if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then fi [[ ! -z ${INPUT_PASSWORD} ]] && SONAR_PASSWORD="${INPUT_PASSWORD}" || SONAR_PASSWORD="" +[[ -z ${INPUT_PROJECTKEY} ]] && SONAR_PROJECTKEY="${PWD##*/}" || SONAR_PROJECTKEY="${INPUT_PROJECTKEY}" sonar-scanner \ -Dsonar.host.url=${INPUT_HOST} \ - -Dsonar.projectKey=${PWD##*/} \ + -Dsonar.projectKey=${SONAR_PROJECTKEY} \ -Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR} \ -Dsonar.login=${INPUT_LOGIN} \ -Dsonar.password=${INPUT_PASSWORD} \