hadolint / hadolint-action

GitHub action for Hadolint, A Dockerfile linting tool
MIT License
192 stars 50 forks source link

Fix Configuration File and 'problem-matcher' Pathing Issue #59

Closed kgrv-me closed 1 year ago

kgrv-me commented 2 years ago

Please refer to #58 for details of the issue(s).

SOLUTIONS

Set default WORKDIR in Dockerfile for easier trace and consistency

WORKDIR /github/workspace

It seems a bit crude to hardcode, it would lock-in that variable.  However, I noticed the repository relies on GitHub environment; this would be just a-okay :D
- OR set the environment variables in `hadolint.sh` for more dynamic approach:

Set essential environment variables in the container

export {PWD,HOME}=$(pwd)

- Prepending `inputs.config` with a little bit of editing:

HADOLINT_CONFIG="-c ${PWD}/${HADOLINT_CONFIG}"


1. Not supplying `inputs.config` with `.hadolint.yaml` present works now!  (it defaults back to `hadolint` configuration file places _INVESTIGATION.0_)
  1. Supply hadolint.yaml to inputs.config also works! (hadolint won't pick up hadolint.yaml by default)
    - uses: kgrv-me/hadolint-action@fix/PathingIssue
    with:
    config: hadolint.yaml

EXTRA ISSUE NOTED

/github/workspace seems intended to be default HOME in hadolint.sh for problem-matcher.json. However, problem-matcher.json never made it ouside the container into the repository as intended due to HOME=/root (INVESTIGATION.6)

Fixing this ticket (pathing issue) via the above methods
would resolve `problem-matcher.json` condition as well!

Cheers!

lorenzo commented 1 year ago

sorry for the late update. Is it possible for you to add a test to the test suite to make sure this actually works?