diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 533c906..8d60349 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -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 ` use `apk add =`"}]' + run: | + if [[ "${OUTPUT}" != "${ASSERT}" ]]; then + echo "::error::Output mismatch: \"${OUTPUT}\" does not equal \"${ASSERT}\"" + exit 1 + fi diff --git a/lib/main.sh b/lib/main.sh index 9613722..f20a83f 100644 --- a/lib/main.sh +++ b/lib/main.sh @@ -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