generated from reviewdog/action-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentrypoint.sh
executable file
·51 lines (44 loc) · 1.51 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
set -e
TERRAFORM_VERSION=$1
if [ -n "${GITHUB_WORKSPACE}" ] ; then
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit 1
git config --global --add safe.directory "${GITHUB_WORKSPACE}" || exit 1
fi
UNAME_ARCH="$(uname -m)"
case "${UNAME_ARCH}" in
x86*) ARCH=amd64;;
arm64) ARCH=arm64;;
aarch64) ARCH=arm64;;
*) echo "Unsupported architecture: ${UNAME_ARCH}. Only AMD64 and ARM64 are supported by the action" && exit 1
esac
wget -q "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_${ARCH}".zip \
&& unzip "./terraform_${TERRAFORM_VERSION}_linux_${ARCH}.zip" -d /usr/local/bin/ \
&& rm -rf "./terraform_${TERRAFORM_VERSION}_linux_${ARCH}.zip"
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"
export TF_TOKEN_app_terraform_io="${INPUT_TERRAFORM_CLOUD_TOKEN}"
jq_script='
.diagnostics[]
| {
severity: (.severity|ascii_upcase),
message: "\(.summary)\n\(.detail)",
location: {
path: .range.filename,
range: {
start: (.range.start|{line, column}),
end: (.range.end|{line, column})},
},
}
'
terraform init -backend=false
# shellcheck disable=SC2086
terraform validate -json \
| jq "$jq_script" -c \
| reviewdog -f="rdjsonl" \
-name="${INPUT_NAME}" \
-reporter="${INPUT_REPORTER:-github-pr-check}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-level="${INPUT_FAIL_LEVEL}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS}