-
-
Notifications
You must be signed in to change notification settings - Fork 394
/
Copy pathentrypoint.sh
executable file
·41 lines (36 loc) · 1.31 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
#!/bin/bash
# Diagnostic output:
echo "Using reporter: $INPUT_REPORTER"
echo "Linting path: $INPUT_PATH"
echo 'flake8 --version:'
flake8 --version
echo '================================='
echo
# Runs `flake8`, possibly with `reviewdog`:
if [ "$INPUT_REPORTER" == 'terminal' ]; then
output=$(flake8 $INPUT_PATH)
status="$?"
elif [ "$INPUT_REPORTER" == 'github-pr-review' ] ||
[ "$INPUT_REPORTER" == 'github-pr-check' ]; then
# We will need this token for `reviewdog` to work:
export REVIEWDOG_GITHUB_API_TOKEN="$GITHUB_TOKEN"
# Running special version of `flake8` to match the `reviewdog` format:
output=$(flake8 $INPUT_PATH --append-config='/action-config.cfg')
echo "$output" | reviewdog -f=pep8 -reporter="$INPUT_REPORTER" -level=error
# `reviewdog` does not fail with any status code, so we have to get dirty:
status=$(test "$output" = ''; echo $?)
else
output="Invalid action reporter specified: $INPUT_REPORTER"
status=1
fi
# Sets the output variable for Github Action API:
# See: https://help.github.com/en/articles/development-tools-for-github-action
echo "::set-output name=output::$output"
echo '================================='
echo
# Fail the build in case status code is not 0:
if [ "$status" != 0 ]; then
echo "$output"
echo "Process failed with the status code: $status"
exit "$status"
fi