14 lines
616 B
Bash
14 lines
616 B
Bash
#!/usr/bin/env bash
|
||
# 用法:entrypoint.sh <files> <severity>;files 是空白分隔的路徑或萬用字元(相對於 workspace),沒有符合的檔案就略過
|
||
set -euo pipefail
|
||
cd "${GITHUB_WORKSPACE:-$PWD}"
|
||
shopt -s nullglob globstar
|
||
# shellcheck disable=SC2206 # 依空白拆開,並由 shell 展開萬用字元(不符合的萬用字元展開成空)
|
||
files=(${1:-*.sh})
|
||
if [ ${#files[@]} -eq 0 ]; then
|
||
echo "沒有符合「${1:-*.sh}」的檔案,略過 shellcheck"
|
||
exit 0
|
||
fi
|
||
echo "shellcheck(嚴重度 ${2:-warning} 以上):${files[*]}"
|
||
exec shellcheck -x -S "${2:-warning}" "${files[@]}"
|