forked from gadiener/ci-templates
-
Notifications
You must be signed in to change notification settings - Fork 5
/
lint-docker.yml
65 lines (52 loc) · 1.63 KB
/
lint-docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
lint:docker:
stage: lint
image: europe-west1-docker.pkg.dev/jobtome-platform/public/hadolint-reviewdog:v1.0.0
script:
- |
COMMAND_TO_RUN="hadolint"
COMMAND_TO_RUN+=( --trusted-registry "docker.io" --trusted-registry "${CI_REGISTRY}" )
if [[ -z "${IGNORE_DOCKER_LINT}" ]]; then
IGNORE_DOCKER_LINT=( DL3012 )
fi
for ign in "${IGNORE_DOCKER_LINT[@]}"; do
COMMAND_TO_RUN+=( --ignore "${ign}" )
done
# Find docker files in a way similar to docker.yml
if [ -z "${IMAGES}" ]; then
COMMAND_TO_RUN+=( ./Dockerfile )
else
if [ -z "${DOCKERFILES_DIR}" ]; then
DOCKERFILES_DIR=docker
fi
for image in ${IMAGES[@]}; do
COMMAND_TO_RUN+=( ./"${DOCKERFILES_DIR}/${image}"/Dockerfile )
done
fi
echo
echo "-> Linting Dockerfile:"
echo
if [ "${ENABLE_REVIEWDOG}" = "1" ]; then
echo
echo "-> Enabled Review Dog!"
echo
if [ -z "${REVIEWDOG_GITLAB_API_TOKEN}" ]; then
echo
echo "-> [WARNING] Missing 'REVIEWDOG_GITLAB_API_TOKEN' variable!"
echo
exit 1
fi
if [ -z "${REVIEWDOG_LEVEL}" ]; then
REVIEWDOG_LEVEL="warning"
fi
"${COMMAND_TO_RUN[@]}" | reviewdog -name="Hadolint linter" \
-efm="%f:%l: %m" -diff="git diff master" -reporter=gitlab-mr-discussion -level="${INPUT_LEVEL}"
else
"${COMMAND_TO_RUN[@]}"
fi
echo
echo "-> Dockerfile(s) checked!"
echo
except:
variables:
- $SKIP_CI_LINT == "true"
- $CI_FAST_TRACK == "true"