-
-
Notifications
You must be signed in to change notification settings - Fork 498
44 lines (44 loc) · 1.92 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
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
# https://github.com/actions/runner-images
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup DietPi-Globals
run: |
sudo mkdir -p /boot/dietpi/func
sudo cp dietpi/func/dietpi-globals /boot/dietpi/func/
sudo ./dietpi/func/dietpi-obtain_hw_model
echo -e 'G_HW_MEMORY_SIZE=1024\nG_HW_ONBOARD_WIFI=1' | sudo tee -a /boot/dietpi/.hw_model
- name: Download shellcheck
run: |
curl -sSfLo shellcheck.tar.xz "$(curl -sSfH 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' 'https://api.github.com/repos/koalaman/shellcheck/releases/latest' | mawk -F\" '/"browser_download_url.*\.linux\.x86_64\.tar\.xz"/{print $4;exit}')"
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 '/^#!.*sh([[:blank:]]|$)/;{exit}' "${FILES[$i]}") ]] && continue # file has shell shebang
unset -v "FILES[$i]" # else remove from array
done
./shellcheck -C -xo all "${FILES[@]}"
rm shellcheck
- name: Check for trailing spaces
if: always()
run: |
! grep -rn --exclude-dir='.git' -I '[[:blank:]]$' .
- name: Check for multiple newlines
if: always()
run: |
! grep -rzPo --exclude-dir='.git' --exclude='*.png' '(^|\n)\N*\n\n\n+\N*(\n|$)' .