Skip to content
Snippets Groups Projects
Commit 7c2764de authored by Eva Bardou's avatar Eva Bardou :frog: Committed by Yoann Schneider
Browse files

Add shellcheck `pre-commit` hook to the base repo and the cookiecutter template

parent 8a87f94f
No related branches found
No related tags found
1 merge request!518Add shellcheck `pre-commit` hook to the base repo and the cookiecutter template
Pipeline #165377 passed
......@@ -41,3 +41,8 @@ repos:
- repo: meta
hooks:
- id: check-useless-excludes
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
exclude: "^worker-{{cookiecutter.slug}}/ci/build.sh$"
\ No newline at end of file
......@@ -15,6 +15,6 @@ if [ -x "$INSTALL_PYTHON" ]; then
elif command -v pre-commit > /dev/null; then
exec pre-commit "${ARGS[@]}"
else
echo '`pre-commit` not found. Did you forget to activate your virtualenv?' 1>&2
echo "\`pre-commit\` not found. Did you forget to activate your virtualenv?" 1>&2
exit 1
fi
......@@ -34,3 +34,7 @@ repos:
- repo: meta
hooks:
- id: check-useless-excludes
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
......@@ -4,19 +4,19 @@
# Will automatically login to a registry if CI_REGISTRY, CI_REGISTRY_USER and CI_REGISTRY_PASSWORD are set.
# Will only push an image if $CI_REGISTRY is set.
if [ -z "$VERSION" -o -z "$CI_PROJECT_DIR" -o -z "$CI_REGISTRY_IMAGE" ]; then
if [ -z "$VERSION" ] || [ -z "$CI_PROJECT_DIR" ] || [ -z "$CI_REGISTRY_IMAGE" ]; then
echo Missing environment variables
exit 1
fi
IMAGE_TAG="$CI_REGISTRY_IMAGE:$VERSION"
cd $CI_PROJECT_DIR
cd "$CI_PROJECT_DIR"
docker build -f Dockerfile . -t "$IMAGE_TAG"
if [ -n "$CI_REGISTRY" -a -n "$CI_REGISTRY_USER" -a -n "$CI_REGISTRY_PASSWORD" ]; then
echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
docker push $IMAGE_TAG
if [ -n "$CI_REGISTRY" ] && [ -n "$CI_REGISTRY_USER" ] && [ -n "$CI_REGISTRY_PASSWORD" ]; then
echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
docker push "$IMAGE_TAG"
else
echo "Missing environment variables to log in to the container registry…"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment