Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

Commit 4f2d830

Browse files
committed
Run shellcheck on github actions
1 parent cee133d commit 4f2d830

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

.github/shellcheck.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
shellcheck "$0"
3+
FAILURES=()
4+
for FILE in bin/*; do
5+
read -r FIRST_LINE < "$FILE"
6+
if [ "${FIRST_LINE}" = "#!/bin/sh" ] || [ "${FIRST_LINE}" = "#!/bin/bash" ]; then
7+
echo "::group::${FILE}"
8+
if ! shellcheck --color=always "$FILE"; then
9+
FAILURES+=("$FILE")
10+
# Re-run, but take JSON and convert it to the format documented here:
11+
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-error-message
12+
shellcheck -f json "$FILE" | jq -r '.[] | "::error file=\(.file),line=\(.line),col=\(.column),endColumn=\(.endColumn),title=SC\(.code): \(.message)::For more information, see https://www.shellcheck.org/wiki/SC\(.code)"'
13+
else
14+
echo "No errors."
15+
fi
16+
echo "::endgroup::"
17+
else
18+
echo "::debug::Skipping $FILE, not a shell script."
19+
fi
20+
done
21+
22+
if [ "${#FAILURES[@]}" -ne 0 ]; then
23+
echo "Failures found in the following files:"
24+
for FILE in "${FAILURES[@]}"; do
25+
echo " $FILE"
26+
done
27+
exit 1
28+
fi
29+
30+
echo "No shellcheck errors."

.github/workflows/shellcheck.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Shellcheck
2+
on:
3+
push:
4+
pull_request:
5+
jobs:
6+
shellcheck:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Shellcheck
11+
run: .github/shellcheck.sh

0 commit comments

Comments
 (0)