1
0
Fork 0
mirror of synced 2026-06-05 15:48:19 +00:00
sonarcloud-github-action/entrypoint.sh
2019-06-04 22:38:11 +02:00

34 lines
869 B
Bash
Executable file

#!/bin/bash
set -e
if [[ -z "${SONAR_TOKEN}" ]]; then
echo "Set the SONAR_TOKEN env variable."
exit 1
fi
if [[ -f "pom.xml" ]]; then
echo "Maven project detected. You should run the goal 'org.sonarsource.scanner.maven:sonar' during build rather than using this GitHub Action."
exit 1
fi
if [[ -f "build.gradle" ]]; then
echo "Gradle project detected. You should use the SonarQube plugin for Gradle during build rather than using this GitHub Action."
exit 1
fi
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
EVENT_ACTION=$(jq -r ".action" "${GITHUB_EVENT_PATH}")
if [[ "${EVENT_ACTION}" != "opened" ]] && [[ "${EVENT_ACTION}" != "synchronize" ]]; then
echo "No need to run analysis"
exit 78
fi
fi
if [[ -z "${SONARCLOUD_URL}" ]]; then
SONARCLOUD_URL="https://sonarcloud.io"
fi
sonar-scanner -Dsonar.host.url=${SONARCLOUD_URL}