Skip to content

Commit

Permalink
Add docker lint pre-commit using hadolint
Browse files Browse the repository at this point in the history
  • Loading branch information
samiwelthomasHO committed Oct 7, 2022
1 parent 7de9e3d commit afa435a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
set -e

JSONNET_FILES_CHANGED=$(git --no-pager diff --cached --name-only --diff-filter=ACM | grep "sonnet" | wc -l)
DOCKERFILE_CHANGED=$(git --no-pager diff --cached --name-only --diff-filter=ACM | grep "Dockerfile" | wc -l)

REPO_ROOT_DIR=$(git rev-parse --show-toplevel)

if [ "$JSONNET_FILES_CHANGED" -gt "0" ]; then
$REPO_ROOT_DIR/monitoring-as-code/fmt.sh
$REPO_ROOT_DIR/monitoring-as-code/lint.sh
git add $REPO_ROOT_DIR
fi

if [ "$DOCKERFILE_CHANGED" -gt "0" ]; then
find $REPO_ROOT_DIR -name Dockerfile -exec sh -c "echo {} && docker run --rm -i ghcr.io/hadolint/hadolint < {}" \;
fi

0 comments on commit afa435a

Please sign in to comment.