Skip to content

Commit

Permalink
Merge pull request #34 from itamargiv/feature/recursive-dir-check
Browse files Browse the repository at this point in the history
Feature: Recursive dir check - Lint multiple files
  • Loading branch information
lorenzo authored Aug 26, 2021
2 parents 0bb0c4c + afcbb72 commit fdf6f4b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ steps:
| Name | Description | Default |
|------------------ |------------------------------------------ |----------------- |
| dockerfile | The path to the Dockerfile to be tested | ./Dockerfile |
| recursive | Search for specified dockerfile | false |
| | recursively, from the project root | |
| format | The output format. One of [tty \| json \| | tty |
| | checkstyle \| codeclimate \| | |
| | gitlab_codeclimate] | |
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ inputs:
required: false
description: 'The path to the Dockerfile to lint'
default: 'Dockerfile'
recursive:
required: false
description: 'Search for specified dockerfile recursively, from the project root'
default: 'false'
format:
required: false
description: |
Expand Down Expand Up @@ -39,6 +43,7 @@ runs:
env:
HADOLINT_CONFIG: ${{ inputs.config }}
HADOLINT_IGNORE: ${{ inputs.ignore }}
HADOLINT_RECURSIVE: ${{ inputs.recursive }}
branding:
icon: 'layers'
color: 'purple'
15 changes: 12 additions & 3 deletions hadolint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# The problem-matcher definition must be present in the repository
# checkout (outside the Docker container running hadolint). We create
Expand Down Expand Up @@ -27,5 +27,14 @@ for i in $HADOLINT_IGNORE; do
HADOLINT_IGNORE_CMDLINE="${HADOLINT_IGNORE_CMDLINE} --ignore=${i}"
done

# shellcheck disable=SC2086
hadolint $HADOLINT_IGNORE_CMDLINE $HADOLINT_CONFIG "$@"
if [ "$HADOLINT_RECURSIVE" = "true" ]; then
shopt -s globstar

filename="${!#}"
flags="${@:1:$#-1}"

hadolint $HADOLINT_IGNORE_CMDLINE $HADOLINT_CONFIG $flags **/$filename
else
# shellcheck disable=SC2086
hadolint $HADOLINT_IGNORE_CMDLINE $HADOLINT_CONFIG "$@"
fi

0 comments on commit fdf6f4b

Please sign in to comment.