Skip to content
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

fix: populate hadolint_output #148

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
21 changes: 21 additions & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,24 @@ jobs:
echo "::error::Version mismatch: \"${HADOLINT_VERSION}\" does not equal \"${REQUESTED_VERSION}\""
exit 1
fi

gh-action-output:
name: Action populates output if configured
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./
id: action-output
with:
dockerfile: "test/fixtures/Dockerfile-valid"
annotate: false
output_format: json
- name: Compare output
env:
OUTPUT: ${{ steps.action-output.outputs.hadolint_output }}
ASSERT: '[{"code":"DL3018","column":1,"file":"test/fixtures/Dockerfile-warning","level":"warning","line":3,"message":"Pin versions in apk add. Instead of `apk add <package>` use `apk add <package>=<version>`"}]'
run: |
if [[ "${OUTPUT}" != "${ASSERT}" ]]; then
echo "::error::Output mismatch: \"${OUTPUT}\" does not equal \"${ASSERT}\""
exit 1
fi
2 changes: 1 addition & 1 deletion lib/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function run() {
# to how output formatting works.
if [[ -n "${OUTPUT_FORMAT}" ]]; then
OUTPUT=$(eval "${HADOLINT_PATH}" --no-fail --no-color "${CONFIG}" -f "${OUTPUT_FORMAT}" "${DOCKERFILE}")
echo "hadolint_output=${OUTPUT//$'\n'/'%0A'} >> \$GITHUB_OUTPUT"
echo \"hadolint_output="${OUTPUT//$'\n'/'%0A'}"\" >>"${GITHUB_OUTPUT}"
fi

# Eval to remove empty vars
Expand Down
Loading