forked from SonarSource/sonarcloud-github-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·34 lines (25 loc) · 945 Bytes
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/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 [[ -z "${SCAN_PULL_REQUEST}" && "${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 78
fi
fi
if [[ -z "${SONARCLOUD_URL}" ]]; then
SONARCLOUD_URL="https://sonarcloud.io"
fi
sonar-scanner -Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR} -Dsonar.host.url=${SONARCLOUD_URL}