-
Notifications
You must be signed in to change notification settings - Fork 652
36 lines (32 loc) · 1.49 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
name: shellcheck
on: [pull_request, push]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
shellcheck:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login
runs-on: ubuntu-24.04
steps:
- name: Install xz-utils
run: |
sudo apt-get -q update
sudo DEBIAN_FRONTEND=noninteractive apt-get -qq --no-install-recommends install xz-utils
- uses: actions/checkout@v4
- name: Download shellcheck
run: |
curl -sSfL "$(curl -sSf 'https://api.github.com/repos/koalaman/shellcheck/releases/latest' | mawk -F\" '/"browser_download_url.*\.linux\.x86_64\.tar\.xz"/{print $4;exit}')" -o shellcheck.tar.xz
tar --wildcards --strip-components=1 -xf shellcheck.tar.xz '*/shellcheck'
rm shellcheck.tar.xz
- name: Run shellcheck
run: |
mapfile -t FILES < <(find . -not \( -path './.git' -prune \) -type f) # read all files to array
for i in "${!FILES[@]}"
do
[[ ${FILES[$i]##*/} =~ '.'[^.]*'sh'$ ]] && continue # file has shell extension
[[ $(mawk 'NR==1 && $0 ~ /^#!.*sh([[:blank:]]|$)/{print;exit}' "${FILES[$i]}") ]] && continue # file has shell shebang
unset -v "FILES[$i]" # else remove from array
done
./shellcheck -xC -o all -e SC2244,SC2250,SC2312 "${FILES[@]}"