Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add include option #110

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ with:
Dockerfile.*
```

### `include`

Optional. Defaults to `*Dockerfile*`. List of folders and files to use for checking.

Use `/%FOLDER%/*` to include whole folder or `%FILENAME%` to include certain files.

Note that you can use wildcard to include certain file extensions, like `Dockerfile.*` will include `Dockerfile.dev`, but will not include `Dockerfile`.

You can combine those rules as you wish (i.e. exclude certain files from certain folders only):
```yaml
with:
include: |
subfolder/Dockerfile.*
```

### `level`

Optional. Report level for reviewdog [`info`, `warning`, `error`].
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ inputs:
exclude:
description: 'List of files and folders to exclude'
default: ''
include:
description: 'List of files and folders to include'
default: '*Dockerfile*'
level:
description: 'Report level for reviewdog [info,warning,error]'
default: 'error'
Expand Down Expand Up @@ -50,6 +53,7 @@ runs:
# https://git.luolix.topmunity/t/input-variable-name-is-not-available-in-composite-run-steps/127611
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
INPUT_EXCLUDE: ${{ inputs.exclude }}
INPUT_INCLUDE: ${{ inputs.include }}
INPUT_HADOLINT_IGNORE: ${{ inputs.hadolint_ignore }}
INPUT_HADOLINT_FLAGS: ${{ inputs.hadolint_flags }}
INPUT_TOOL_NAME: ${{ inputs.tool_name }}
Expand Down
8 changes: 7 additions & 1 deletion script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ for exclude_path in $INPUT_EXCLUDE; do
EXCLUDES="$EXCLUDES $*"
done

INCLUDES=""
for include_path in $INPUT_INCLUDE; do
set -- --exclude="${include_path}"
INCLUDES="$INCLUDES $*"
done

IGNORE_LIST=""
for rule in $INPUT_HADOLINT_IGNORE; do
IGNORE_LIST="$IGNORE_LIST --ignore $rule"
Expand All @@ -32,7 +38,7 @@ done
INPUT_HADOLINT_FLAGS="$INPUT_HADOLINT_FLAGS $IGNORE_LIST"

echo '::group:: Running hadolint with reviewdog 🐶 ...'
git ls-files --exclude='*Dockerfile*' --ignored --cached ${EXCLUDES} \
git ls-files ${INCLUDES} --ignored --cached ${EXCLUDES} \
| xargs hadolint -f json ${INPUT_HADOLINT_FLAGS} \
| jq -f "${GITHUB_ACTION_PATH}/to-rdjson.jq" -c \
| reviewdog -f="rdjson" \
Expand Down