1+ name : Lint Scripts
2+
3+ on :
4+ push :
5+ branches : [main]
6+ paths :
7+ - ' scripts/**.sh'
8+ - ' **.lua'
9+ - ' .github/workflows/scripts-lint.yml'
10+ pull_request :
11+ branches : [main]
12+ paths :
13+ - ' scripts/**.sh'
14+ - ' **.lua'
15+ - ' .github/workflows/scripts-lint.yml'
16+
17+ jobs :
18+ shellcheck :
19+ runs-on : ubuntu-latest
20+ steps :
21+ - uses : actions/checkout@v3
22+ - name : Install shellcheck
23+ run : sudo apt-get update && sudo apt-get install -y shellcheck
24+ - name : List shell scripts
25+ id : list-scripts
26+ run : |
27+ if [[ -d "./scripts" && $(find ./scripts -name "*.sh" | wc -l) -gt 0 ]]; then
28+ echo "SHELL_SCRIPTS_EXIST=true" >> $GITHUB_ENV
29+ find ./scripts -name "*.sh" -type f
30+ else
31+ echo "SHELL_SCRIPTS_EXIST=false" >> $GITHUB_ENV
32+ echo "No shell scripts found in ./scripts directory"
33+ fi
34+ - name : Run shellcheck
35+ if : env.SHELL_SCRIPTS_EXIST == 'true'
36+ run : |
37+ echo "Running shellcheck on shell scripts:"
38+ find ./scripts -name "*.sh" -type f -print0 | xargs -0 shellcheck --severity=warning
39+
40+ luacheck :
41+ runs-on : ubuntu-latest
42+ steps :
43+ - uses : actions/checkout@v3
44+ - name : Check for Lua files
45+ id : check-lua
46+ run : |
47+ if [[ $(find . -name "*.lua" | wc -l) -gt 0 ]]; then
48+ echo "LUA_FILES_EXIST=true" >> $GITHUB_ENV
49+ find . -name "*.lua" -type f | head -5
50+ else
51+ echo "LUA_FILES_EXIST=false" >> $GITHUB_ENV
52+ echo "No Lua files found in repository"
53+ fi
54+ - name : Set up Lua
55+ if : env.LUA_FILES_EXIST == 'true'
56+ uses : leafo/gh-actions-lua@v9
57+ with :
58+ luaVersion : " 5.1"
59+ - name : Set up LuaRocks
60+ if : env.LUA_FILES_EXIST == 'true'
61+ uses : leafo/gh-actions-luarocks@v4
62+ - name : Install luacheck
63+ if : env.LUA_FILES_EXIST == 'true'
64+ run : luarocks install luacheck
65+ - name : Run luacheck
66+ if : env.LUA_FILES_EXIST == 'true'
67+ run : luacheck .
0 commit comments