forked from armbian/build
-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (43 loc) · 1.62 KB
/
pr-lint-scripts.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
58
59
name: Lint on Scripts
run-name: 'Shellcheck - PR #${{ github.event.pull_request.number }} ("${{ github.event.pull_request.title }}")'
#
# Run ShellCheck on all scripts and generate report as build artifact
#
on:
workflow_dispatch:
pull_request:
types: [opened, reopened, synchronize]
permissions:
contents: read
concurrency:
group: pipeline-lint-${{github.event.pull_request.number}}
cancel-in-progress: true
jobs:
Shellcheck:
name: Shell script analysis
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'Armbian' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
- name: List all changed files
run: |
# Use framework internal mechanism for checking `lib` and `extensions` code only one file is passed,
# and source's are followed, thus the whole project is "understood" by shellcheck.
# For example, when checking individual files, one variable might be thought "unused" because it
# is only used in another file, which does not happen when done properly.
bash lib/tools/shellcheck.sh
ret=0
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [[ ! "${file}" =~ lib/|extensions/|.py|.service|.rules|.network|.netdev ]]; then
if grep -qE "^#\!/.*bash" $file; then
shellcheck --severity=error $file || ret=$?
fi
fi
done
exit $ret