diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 277c0d8..ba3bfb3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,23 +79,7 @@ jobs: - name: Run integration test 6 - verify results output parameter # This step will never fail, but will print out the results from step5 - env: - results: ${{ steps.hadolint5.outputs.results }} - run: echo "$results" - - - name: Run integration test 7 - set recursive - uses: ./ - with: - dockerfile: "*Dockerfile" - failure-threshold: error - recursive: true - - - name: Run integration test 8 - print results to console - uses: ./ - with: - dockerfile: testdata/warning.Dockerfile - failure-threshold: error - results-to-console: true + run: echo "${{ steps.hadolint5.outputs.results }}" #- name: Run integration test 6 - output to file # # This step will never fail, but will print out rule violations. diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 485dee6..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.idea diff --git a/README.md b/README.md index 7d6fd9a..3e3809e 100644 --- a/README.md +++ b/README.md @@ -23,24 +23,23 @@ steps: ## Inputs -| Name | Description | Default | -|----------------------|-------------------------------------------------------------------------------------------------------------------------------|--------------------| -| `dockerfile` | The path to the Dockerfile to be tested | `./Dockerfile` | -| `recursive` | Search for specified dockerfile
recursively, from the project root | `false` | -| `config` | Custom path to a Hadolint config file | `./.hadolint.yaml` | -| `output-file` | A sub-path where to save the
output as a file to | | -| `results-to-console` | The flag to print Hadolint results to console | `false` | -| `no-color` | Don't create colored output (`true`/`false`) | | -| `no-fail` | Never fail the action (`true`/`false`) | | -| `verbose` | Output more information (`true`/`false`) | | -| `format` | The output format. One of [`tty` \ | `json` \|
`checkstyle` \| `codeclimate` \|
`gitlab_codeclimate` \| `codacy` \| `sarif`] | `tty` | -| `failure-threshold` | Rule severity threshold for pipeline
failure. One of [`error` \ | `warning` \|
`info` \| `style` \| `ignore`] | `info` | -| `override-error` | Comma separated list of rules to treat with `error` severity | | -| `override-warning` | Comma separated list of rules to treat with `warning` severity | | -| `override-info` | Comma separated list of rules to treat with `info` severity | | -| `override-style` | Comma separated list of rules to treat with `style` severity | | -| `ignore` | Comma separated list of Hadolint rules to ignore. | | -| `trusted-registries` | Comma separated list of urls of trusted registries | | +| Name | Description | Default | +|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------|--------------------| +| `dockerfile` | The path to the Dockerfile to be tested | `./Dockerfile` | +| `recursive` | Search for specified dockerfile
recursively, from the project root | `false` | +| `config` | Custom path to a Hadolint config file | `./.hadolint.yaml` | +| `output-file` | A sub-path where to save the
output as a file to | | +| `no-color` | Don't create colored output (`true`/`false`) | | +| `no-fail` | Never fail the action (`true`/`false`) | | +| `verbose` | Output more information (`true`/`false`) | | +| `format` | The output format. One of [`tty` \| `json` \|
`checkstyle` \| `codeclimate` \|
`gitlab_codeclimate` \| `codacy` \| `sarif`] | `tty` | +| `failure-threshold` | Rule severity threshold for pipeline
failure. One of [`error` \| `warning` \|
`info` \| `style` \| `ignore`] | `info` | +| `override-error` | Comma separated list of rules to treat with `error` severity | | +| `override-warning` | Comma separated list of rules to treat with `warning` severity | | +| `override-info` | Comma separated list of rules to treat with `info` severity | | +| `override-style` | Comma separated list of rules to treat with `style` severity | | +| `ignore` | Comma separated list of Hadolint rules to ignore. | | +| `trusted-registries` | Comma separated list of urls of trusted registries | | ## Output diff --git a/action.yml b/action.yml index f0fa9ab..e1c9fba 100644 --- a/action.yml +++ b/action.yml @@ -19,10 +19,7 @@ inputs: required: false description: 'The path where to save the linting results to' default: "/dev/stdout" - results-to-console: - required: false - description: 'The flag to print Hadolint results to console' - default: false + # standart hadolint options: no-color: required: false @@ -98,7 +95,6 @@ runs: HADOLINT_CONFIG: ${{ inputs.config }} HADOLINT_RECURSIVE: ${{ inputs.recursive }} HADOLINT_OUTPUT: ${{ inputs.output-file }} - HADOLINT_RESULTS_TO_CONSOLE: ${{ inputs.results-to-console }} branding: icon: 'layers' color: 'purple' diff --git a/hadolint.sh b/hadolint.sh index af507de..4231068 100755 --- a/hadolint.sh +++ b/hadolint.sh @@ -3,10 +3,7 @@ # The problem-matcher definition must be present in the repository # checkout (outside the Docker container running hadolint). We copy # problem-matcher.json to the home folder. -PROBLEM_MATCHER_FILE="/problem-matcher.json" -if [ -f "$PROBLEM_MATCHER_FILE" ]; then - cp "$PROBLEM_MATCHER_FILE" "$HOME/" -fi +cp /problem-matcher.json "$HOME/" # After the run has finished we remove the problem-matcher.json from # the repository so we don't leave the checkout dirty. We also remove @@ -26,18 +23,16 @@ if [ -z "$HADOLINT_TRUSTED_REGISTRIES" ]; then unset HADOLINT_TRUSTED_REGISTRIES; fi -COMMAND="hadolint $HADOLINT_CONFIG" - if [ "$HADOLINT_RECURSIVE" = "true" ]; then shopt -s globstar filename="${!#}" flags="${@:1:$#-1}" - RESULTS=$(eval "$COMMAND $flags" -- **/$filename) + RESULTS=$(hadolint $HADOLINT_CONFIG $flags **/$filename) else - - RESULTS=$(eval "$COMMAND" "$@") + # shellcheck disable=SC2086 + RESULTS=$(hadolint $HADOLINT_CONFIG "$@") fi FAILED=$? @@ -45,18 +40,16 @@ if [ -n "$HADOLINT_OUTPUT" ]; then if [ -f "$HADOLINT_OUTPUT" ]; then HADOLINT_OUTPUT="$TMP_FOLDER/$HADOLINT_OUTPUT" fi - echo "$RESULTS" > "$HADOLINT_OUTPUT" -fi - -if [ "$HADOLINT_RESULTS_TO_CONSOLE" = "true" ]; then - echo "$RESULTS" + echo "$RESULTS" > $HADOLINT_OUTPUT fi RESULTS="${RESULTS//$'\\n'/''}" -{ echo "results<> "$GITHUB_OUTPUT" +echo "results<> $GITHUB_OUTPUT +echo "${RESULTS}" >> $GITHUB_OUTPUT +echo "EOF" >> $GITHUB_OUTPUT -{ echo "HADOLINT_RESULTS<> "$GITHUB_ENV" +{ echo "HADOLINT_RESULTS<> $GITHUB_ENV [ -z "$HADOLINT_OUTPUT" ] || echo "Hadolint output saved to: $HADOLINT_OUTPUT"