From 34545a185d851450627a7f76c0369ec9cce26950 Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Mon, 31 May 2021 13:57:42 +0200 Subject: [PATCH 1/2] Add recursive linting --- action.yml | 5 +++++ hadolint.sh | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index e5163ab..5dd038f 100644 --- a/action.yml +++ b/action.yml @@ -6,6 +6,10 @@ inputs: required: false description: 'The path to the Dockerfile to lint' default: 'Dockerfile' + recursive: + required: false + description: 'Search for lint dockerfiles recuresivly' + default: 'false' format: required: false description: | @@ -39,6 +43,7 @@ runs: env: HADOLINT_CONFIG: ${{ inputs.config }} HADOLINT_IGNORE: ${{ inputs.ignore }} + HADOLINT_RECURSIVE: ${{ inputs.recursive }} branding: icon: 'layers' color: 'purple' diff --git a/hadolint.sh b/hadolint.sh index e74c807..243bc86 100755 --- a/hadolint.sh +++ b/hadolint.sh @@ -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 @@ -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 From afcbb72a700aeb4430d3511378773ad36db4ae16 Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Mon, 31 May 2021 17:49:14 +0200 Subject: [PATCH 2/2] Update docs --- README.md | 2 ++ action.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cd4121d..5affe47 100644 --- a/README.md +++ b/README.md @@ -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] | | diff --git a/action.yml b/action.yml index 5dd038f..aff7df6 100644 --- a/action.yml +++ b/action.yml @@ -8,7 +8,7 @@ inputs: default: 'Dockerfile' recursive: required: false - description: 'Search for lint dockerfiles recuresivly' + description: 'Search for specified dockerfile recursively, from the project root' default: 'false' format: required: false