Skip to content

Commit

Permalink
update(entrypoint): remove conditional trigger event & dynamic source…
Browse files Browse the repository at this point in the history
… encoding

and code-style
  • Loading branch information
dwisiswant0 committed Jun 16, 2022
1 parent 70d39d8 commit 214c4b6
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@

set -e

if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
EVENT_ACTION=$(jq -r ".action" "${GITHUB_EVENT_PATH}")
if [[ "${EVENT_ACTION}" != "opened" ]]; then
echo "No need to run analysis. It is already triggered by the push event."
exit
fi
fi

REPOSITORY_NAME=$(basename "${GITHUB_REPOSITORY}")

if [[ ! -z ${INPUT_PASSWORD} ]]; then
if [[ ! -z "${INPUT_PASSWORD}" ]]; then
echo "::warning ::Running this GitHub Action without authentication token is NOT recommended!"
SONAR_PASSWORD="${INPUT_PASSWORD}"
else
Expand All @@ -32,9 +24,9 @@ fi
unset JAVA_HOME

if [[ ! -f "${INPUT_PROJECTBASEDIR%/}sonar-project.properties" ]]; then
[[ -z ${INPUT_PROJECTKEY} ]] && SONAR_PROJECTKEY="${REPOSITORY_NAME}" || SONAR_PROJECTKEY="${INPUT_PROJECTKEY}"
[[ -z ${INPUT_PROJECTNAME} ]] && SONAR_PROJECTNAME="${REPOSITORY_NAME}" || SONAR_PROJECTNAME="${INPUT_PROJECTNAME}"
[[ -z ${INPUT_PROJECTVERSION} ]] && SONAR_PROJECTVERSION="" || SONAR_PROJECTVERSION="${INPUT_PROJECTVERSION}"
[[ -z "${INPUT_PROJECTKEY}" ]] && SONAR_PROJECTKEY="${REPOSITORY_NAME}" || SONAR_PROJECTKEY="${INPUT_PROJECTKEY}"
[[ -z "${INPUT_PROJECTNAME}" ]] && SONAR_PROJECTNAME="${REPOSITORY_NAME}" || SONAR_PROJECTNAME="${INPUT_PROJECTNAME}"
[[ -z "${INPUT_PROJECTVERSION}" ]] && SONAR_PROJECTVERSION="" || SONAR_PROJECTVERSION="${INPUT_PROJECTVERSION}"
sonar-scanner \
-Dsonar.host.url=${INPUT_HOST} \
-Dsonar.projectKey=${SONAR_PROJECTKEY} \
Expand All @@ -44,7 +36,7 @@ if [[ ! -f "${INPUT_PROJECTBASEDIR%/}sonar-project.properties" ]]; then
-Dsonar.login=${INPUT_LOGIN} \
-Dsonar.password=${SONAR_PASSWORD} \
-Dsonar.sources=. \
-Dsonar.sourceEncoding=UTF-8
-Dsonar.sourceEncoding=${INPUT_ENCODING}
else
sonar-scanner \
-Dsonar.host.url=${INPUT_HOST} \
Expand Down

0 comments on commit 214c4b6

Please sign in to comment.