Skip to content

Pass the job if no warnings #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions script.sh

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [shellcheck] reported by reviewdog 🐶
Expressions don't expand in single quotes, use double quotes for that. SC2016

docker_build_jq='{

Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,25 @@ diagnostics: .warnings | map({
})
}'

docker_files=$(git ls-files --exclude='*Dockerfile*' --ignored --cached)
docker_files=($(git ls-files --exclude='*Dockerfile*' --ignored --cached))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [shellcheck] reported by reviewdog 🐶
Prefer mapfile or read -a to split command output (or quote to avoid splitting). SC2207


for docker_file in "${docker_files[@]}" ; do
export DOCKER_FILE_PATH=${docker_file}

echo "::group:: docker build -f ${docker_file} --call=check,format=json"
check_result=$(docker build -f "${docker_file}" --call=check,format=json . || true)
echo "::group:: result of build --check"
echo "::endgroup::"

echo "::group:: result of ${docker_file}"
echo "$check_result"
echo "::endgroups::"

warnings=$(echo "$check_result" | jq '.warnings')
if [[ "$warnings" == "null" ]]; then
echo "No warnings found in ${docker_file}"
continue
fi

export DOCKER_FILE_PATH=${docker_file}
echo "$check_result" | jq "$docker_build_jq" \
| reviewdog -f=rdjson -name="docker-build-check" \
-reporter="${INPUT_REPORTER}" \
Expand Down
1 change: 1 addition & 0 deletions testdata/no_warnings/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM alpine
File renamed without changes.