forked from PolyArch/humanize
-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (55 loc) · 1.66 KB
/
shell-syntax-check.yml
File metadata and controls
61 lines (55 loc) · 1.66 KB
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
60
61
name: Shell Syntax Check
on:
push:
branches: ['**']
pull_request:
branches: ['**']
jobs:
shell-syntax-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install zsh
run: sudo apt-get update && sudo apt-get install -y zsh
- name: Find all shell scripts
id: find-scripts
run: |
scripts=$(find . -name "*.sh" -type f | sort)
echo "Found shell scripts:"
echo "$scripts"
echo "scripts<<EOF" >> $GITHUB_OUTPUT
echo "$scripts" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Check bash syntax
run: |
echo "Checking bash syntax for all .sh files..."
exit_code=0
while IFS= read -r script; do
if [ -n "$script" ]; then
echo "Checking: $script"
if bash -n "$script"; then
echo " bash: OK"
else
echo " bash: FAILED"
exit_code=1
fi
fi
done <<< "${{ steps.find-scripts.outputs.scripts }}"
exit $exit_code
- name: Check zsh syntax
run: |
echo "Checking zsh syntax for all .sh files..."
exit_code=0
while IFS= read -r script; do
if [ -n "$script" ]; then
echo "Checking: $script"
if zsh -n "$script"; then
echo " zsh: OK"
else
echo " zsh: FAILED"
exit_code=1
fi
fi
done <<< "${{ steps.find-scripts.outputs.scripts }}"
exit $exit_code