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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#!/bin/sh
set -e
echo "[INF] Running $0"
VERSION=$(shellcheck --version | grep 'version:' | cut -d ' ' -f2)
if [ "$VERSION" = "" ]; then
echo "[ERR] shellcheck is not installed!"
exit 1
fi
echo "[INF] shellcheck version [$VERSION]"
echo "[INF] Running shellcheck..."
echo "[INF] Generating tty output..."
OUTPUT_TTY="$(shellcheck --format=tty \
configure \
app/test/*.sh \
scripts/*.sh \
setup-action/scripts/*.bash 2>&1 || true)"
echo "[INF] Generating diff output..."
OUTPUT_DIFF="$(shellcheck --format=diff \
configure \
app/test/*.sh \
scripts/*.sh \
setup-action/scripts/*.bash 2>&1 || true)"
if [ "$OUTPUT_TTY" != "" ] && [ "$OUTPUT_DIFF" != "" ]; then
echo "[ERR] Issues found!"
echo "[ERR] Dumping tty output..."
echo "$OUTPUT_TTY"
echo "[ERR] Dumping diff output..."
echo "$OUTPUT_DIFF"
else
echo "[INF] No issues found!"
fi
if [ "$CI" = true ]; then
echo "[INF] Generating Markdown step summary..."
{
if [ "$OUTPUT_TTY" != "" ] && [ "$OUTPUT_DIFF" != "" ]; then
echo "<details>"
echo "<summary>Shellcheck Summary (tty format)</summary>"
echo
echo '```'
echo "$OUTPUT_TTY"
echo '```'
echo
echo "</details>"
echo
echo "<details>"
echo "<summary>Shellcheck Summary (diff format)</summary>"
echo
echo '```diff'
echo "$OUTPUT_DIFF"
echo '```'
echo "</details>"
else
echo "No issues found!"
fi
} >>"$GITHUB_STEP_SUMMARY"
fi
echo "[INF] shellcheck ran successfully!"
echo "[INF] --- [DONE] ---"
|