-
-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (50 loc) · 1.84 KB
/
shellcheck.yml
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
name: Shellcheck Lint
on:
push:
paths:
# Run workflow on every push
# only if a file within the specified paths has been changed:
- '*.sh'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
name: Shellcheck Lint
# This job runs on Linux
runs-on: ubuntu-latest
steps:
# Required to access files of this repository
- uses: actions/checkout@master
# Download Shellcheck and add it to the workflow path
- name: Download Shellcheck
run: |
wget -qO- "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz" | tar -xJv
chmod +x shellcheck-stable/shellcheck
# Verify that Shellcheck can be executed
- name: Check Shellcheck Version
run: |
shellcheck-stable/shellcheck --version
# Run Shellcheck on repository
# ---
# https://github.com/koalaman/shellcheck
# ---
# Excluded checks:
# https://www.shellcheck.net/wiki/SC1091 -- Not following: /etc/rc.status was...
# https://www.shellcheck.net/wiki/SC1090 -- Can't follow non-constant source. ..
# ---
- name: Run Shellcheck
run: |
rm -f ./some_scripts_have_failed_shellcheck
set +e
find ./ -type f -name "*.sh"| sort | while read -r sh; do
if [ "$(file --brief --mime-type "$sh")" == 'text/x-shellscript' ]; then
echo "shellcheck'ing $sh"
if ! shellcheck-stable/shellcheck --color=always --severity=warning "$sh"; then
touch some_scripts_have_failed_shellcheck
fi
fi
done
if [ -f ./some_scripts_have_failed_shellcheck ]; then
echo "Shellcheck failed for one or more shellscript(s)"
exit 1
fi