#!/bin/sh

DESTINATION="--destination ${DOCKER_HUB_REPO}:${CI_COMMIT_BRANCH} --destination ${DOCKER_HUB_REPO}:${VERSION}-${CI_COMMIT_SHORT_SHA}"

if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then
    DESTINATION="$DESTINATION --destination ${DOCKER_HUB_REPO}:${VERSION} --destination ${DOCKER_HUB_REPO}:latest"
fi

/kaniko/executor --context . ${DESTINATION} --build-arg VERSION=$VERSION