mirror of
https://github.com/ludeeus/action-shellcheck.git
synced 2024-08-16 10:09:53 +02:00
Use INPUT_* for input env to match documentation (#71)
This commit is contained in:
parent
45e81d0a30
commit
3d0de11d23
1 changed files with 34 additions and 39 deletions
73
action.yaml
73
action.yaml
|
@ -59,18 +59,18 @@ runs:
|
||||||
- name: Enable problem-matcher
|
- name: Enable problem-matcher
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
format: ${{ inputs.format }}
|
INPUT_FORMAT: ${{ inputs.format }}
|
||||||
disable_matcher: ${{ inputs.disable_matcher }}
|
INPUT_DISABLE_MATCHER: ${{ inputs.disable_matcher }}
|
||||||
run: |
|
run: |
|
||||||
problem_matcher_file="${{ github.action_path }}/.github/problem-matcher-${format}.json"
|
problem_matcher_file="${{ github.action_path }}/.github/problem-matcher-${INPUT_FORMAT}.json"
|
||||||
if [[ "${disable_matcher}" != "true" && -f "$problem_matcher_file" ]]; then
|
if [[ "${INPUT_DISABLE_MATCHER}" != "true" && -f "$problem_matcher_file" ]]; then
|
||||||
echo "::add-matcher::$problem_matcher_file"
|
echo "::add-matcher::$problem_matcher_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Download shellcheck
|
- name: Download shellcheck
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
scversion: ${{ inputs.version }}
|
INPUT_VERSION: ${{ inputs.version }}
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ runner.os }}" == "macOS" ]]; then
|
if [[ "${{ runner.os }}" == "macOS" ]]; then
|
||||||
osvariant="darwin"
|
osvariant="darwin"
|
||||||
|
@ -81,38 +81,33 @@ runs:
|
||||||
baseurl="https://github.com/koalaman/shellcheck/releases/download"
|
baseurl="https://github.com/koalaman/shellcheck/releases/download"
|
||||||
|
|
||||||
curl -Lso "${{ github.action_path }}/sc.tar.xz" \
|
curl -Lso "${{ github.action_path }}/sc.tar.xz" \
|
||||||
"${baseurl}/${scversion}/shellcheck-${scversion}.${osvariant}.x86_64.tar.xz"
|
"${baseurl}/${INPUT_VERSION}/shellcheck-${INPUT_VERSION}.${osvariant}.x86_64.tar.xz"
|
||||||
|
|
||||||
tar -xf "${{ github.action_path }}/sc.tar.xz" -C "${{ github.action_path }}"
|
tar -xf "${{ github.action_path }}/sc.tar.xz" -C "${{ github.action_path }}"
|
||||||
mv "${{ github.action_path }}/shellcheck-${scversion}/shellcheck" \
|
mv "${{ github.action_path }}/shellcheck-${INPUT_VERSION}/shellcheck" \
|
||||||
"${{ github.action_path }}/shellcheck"
|
"${{ github.action_path }}/shellcheck"
|
||||||
|
|
||||||
- name: Display shellcheck version
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
"${{ github.action_path }}/shellcheck" --version
|
|
||||||
|
|
||||||
- name: Set options
|
- name: Set options
|
||||||
shell: bash
|
shell: bash
|
||||||
id: options
|
id: options
|
||||||
env:
|
env:
|
||||||
severity: ${{ inputs.severity }}
|
INPUT_SEVERITY: ${{ inputs.severity }}
|
||||||
format: ${{ inputs.format }}
|
INPUT_FORMAT: ${{ inputs.format }}
|
||||||
run: |
|
run: |
|
||||||
declare -a options
|
declare -a options
|
||||||
if [[ -n "${severity}" ]]; then
|
if [[ -n "${INPUT_SEVERITY}" ]]; then
|
||||||
options+=("-S ${severity}")
|
options+=("-S ${INPUT_SEVERITY}")
|
||||||
fi
|
fi
|
||||||
options+=("--format=${format}")
|
options+=("--format=${INPUT_FORMAT}")
|
||||||
echo "options=${options[@]}" >> $GITHUB_OUTPUT
|
echo "options=${options[@]}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Gather excluded paths
|
- name: Gather excluded paths
|
||||||
shell: bash
|
shell: bash
|
||||||
id: exclude
|
id: exclude
|
||||||
env:
|
env:
|
||||||
ignore: ${{ inputs.ignore }}
|
INPUT_IGNORE: ${{ inputs.ignore }}
|
||||||
ignore_paths: ${{ inputs.ignore_paths }}
|
INPUT_IGNORE_PATHS: ${{ inputs.ignore_paths }}
|
||||||
ignore_names: ${{ inputs.ignore_names }}
|
INPUT_IGNORE_NAMES: ${{ inputs.ignore_names }}
|
||||||
run: |
|
run: |
|
||||||
declare -a excludes
|
declare -a excludes
|
||||||
set -f # temporarily disable globbing so that globs in input aren't expanded
|
set -f # temporarily disable globbing so that globs in input aren't expanded
|
||||||
|
@ -120,16 +115,16 @@ runs:
|
||||||
excludes+=("! -path *./.git/*")
|
excludes+=("! -path *./.git/*")
|
||||||
excludes+=("! -path *.go")
|
excludes+=("! -path *.go")
|
||||||
excludes+=("! -path */mvnw")
|
excludes+=("! -path */mvnw")
|
||||||
if [[ -n "${ignore}" ]]; then
|
if [[ -n "${INPUT_IGNORE}" ]]; then
|
||||||
echo "::warning::ignore is deprecated. Please use ignore_paths instead"
|
echo "::warning::ignore is deprecated. Please use ignore_paths instead"
|
||||||
for path in ${ignore}; do
|
for path in ${INPUT_IGNORE}; do
|
||||||
echo "::debug:: Adding '$path' to excludes"
|
echo "::debug:: Adding '$path' to excludes"
|
||||||
excludes+=("! -path *./$path/*")
|
excludes+=("! -path *./$path/*")
|
||||||
excludes+=("! -path */$path/*")
|
excludes+=("! -path */$path/*")
|
||||||
excludes+=("! -path $path")
|
excludes+=("! -path $path")
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
for path in ${ignore_paths}; do
|
for path in ${INPUT_IGNORE_PATHS}; do
|
||||||
echo "::debug:: Adding '$path' to excludes"
|
echo "::debug:: Adding '$path' to excludes"
|
||||||
excludes+=("! -path *./$path/*")
|
excludes+=("! -path *./$path/*")
|
||||||
excludes+=("! -path */$path/*")
|
excludes+=("! -path */$path/*")
|
||||||
|
@ -137,7 +132,7 @@ runs:
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for name in ${ignore_names}; do
|
for name in ${INPUT_IGNORE_NAMES}; do
|
||||||
echo "::debug:: Adding '$name' to excludes"
|
echo "::debug:: Adding '$name' to excludes"
|
||||||
excludes+=("! -name $name")
|
excludes+=("! -name $name")
|
||||||
done
|
done
|
||||||
|
@ -149,10 +144,10 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
id: additional
|
id: additional
|
||||||
env:
|
env:
|
||||||
additional_files: ${{ inputs.additional_files }}
|
INPUT_ADDITIONAL_FILES: ${{ inputs.additional_files }}
|
||||||
run: |
|
run: |
|
||||||
declare -a files
|
declare -a files
|
||||||
for file in ${additional_files}; do
|
for file in ${INPUT_ADDITIONAL_FILES}; do
|
||||||
echo "::debug:: Adding '$file' to additional files"
|
echo "::debug:: Adding '$file' to additional files"
|
||||||
files+=("-o -name *$file")
|
files+=("-o -name *$file")
|
||||||
done
|
done
|
||||||
|
@ -162,11 +157,11 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
id: check
|
id: check
|
||||||
env:
|
env:
|
||||||
scandir: ${{ inputs.scandir }}
|
INPUT_SCANDIR: ${{ inputs.scandir }}
|
||||||
check_together: ${{ inputs.check_together }}
|
INPUT_CHECK_TOGETHER: ${{ inputs.check_together }}
|
||||||
exclude_args: ${{ steps.exclude.outputs.excludes }}
|
INPUT_EXCLUDE_ARGS: ${{ steps.exclude.outputs.excludes }}
|
||||||
additional_file_args: ${{ steps.additional.outputs.files }}
|
INPUT_ADDITIONAL_FILE_ARGS: ${{ steps.additional.outputs.files }}
|
||||||
shellcheck_options: ${{ steps.options.outputs.options }}
|
INPUT_SHELLCHECK_OPTIONS: ${{ steps.options.outputs.options }}
|
||||||
run: |
|
run: |
|
||||||
statuscode=0
|
statuscode=0
|
||||||
declare -a filepaths
|
declare -a filepaths
|
||||||
|
@ -176,8 +171,8 @@ runs:
|
||||||
|
|
||||||
while IFS= read -r -d '' file; do
|
while IFS= read -r -d '' file; do
|
||||||
filepaths+=("$file")
|
filepaths+=("$file")
|
||||||
done < <(find "${scandir}" \
|
done < <(find "${INPUT_SCANDIR}" \
|
||||||
${exclude_args} \
|
${INPUT_EXCLUDE_ARGS} \
|
||||||
-type f \
|
-type f \
|
||||||
'(' \
|
'(' \
|
||||||
-name '*.bash' \
|
-name '*.bash' \
|
||||||
|
@ -206,27 +201,27 @@ runs:
|
||||||
-o -path '*/.profile' \
|
-o -path '*/.profile' \
|
||||||
-o -path '*/profile' \
|
-o -path '*/profile' \
|
||||||
-o -name '*.shlib' \
|
-o -name '*.shlib' \
|
||||||
${additional_file_args} \
|
${INPUT_ADDITIONAL_FILE_ARGS} \
|
||||||
')' \
|
')' \
|
||||||
-print0)
|
-print0)
|
||||||
|
|
||||||
while IFS= read -r -d '' file; do
|
while IFS= read -r -d '' file; do
|
||||||
head -n1 "$file" | grep -Eqs "$shebangregex" || continue
|
head -n1 "$file" | grep -Eqs "$shebangregex" || continue
|
||||||
filepaths+=("$file")
|
filepaths+=("$file")
|
||||||
done < <(find "${scandir}" \
|
done < <(find "${INPUT_SCANDIR}" \
|
||||||
${exclude_args} \
|
${INPUT_EXCLUDE_ARGS} \
|
||||||
-type f ! -name '*.*' -perm /111 \
|
-type f ! -name '*.*' -perm /111 \
|
||||||
-print0)
|
-print0)
|
||||||
|
|
||||||
if [[ -n "${check_together}" ]]; then
|
if [[ -n "${INPUT_CHECK_TOGETHER}" ]]; then
|
||||||
"${{ github.action_path }}/shellcheck" \
|
"${{ github.action_path }}/shellcheck" \
|
||||||
${shellcheck_options} \
|
${INPUT_SHELLCHECK_OPTIONS} \
|
||||||
"${filepaths[@]}" || statuscode=$?
|
"${filepaths[@]}" || statuscode=$?
|
||||||
else
|
else
|
||||||
for file in "${filepaths[@]}"; do
|
for file in "${filepaths[@]}"; do
|
||||||
echo "::debug::Checking '$file'"
|
echo "::debug::Checking '$file'"
|
||||||
"${{ github.action_path }}/shellcheck" \
|
"${{ github.action_path }}/shellcheck" \
|
||||||
${shellcheck_options} \
|
${INPUT_SHELLCHECK_OPTIONS} \
|
||||||
"$file" || statuscode=$?
|
"$file" || statuscode=$?
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue