2020-06-19 17:38:55 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -ex
|
|
|
|
|
2020-07-13 16:47:47 +00:00
|
|
|
slugify() {
|
2020-08-14 15:35:50 +00:00
|
|
|
echo "$1" | sed -r 's/[^.a-zA-Z0-9]+/-/g'
|
2020-07-13 16:47:47 +00:00
|
|
|
}
|
|
|
|
|
2020-06-19 17:38:55 +00:00
|
|
|
export IMAGE="openebs/rawfile-localpv"
|
|
|
|
export COMMIT=$(git rev-parse --short HEAD)
|
|
|
|
export BRANCH=${TRAVIS_BRANCH:-$(git rev-parse --abbrev-ref HEAD)}
|
2020-07-13 16:47:47 +00:00
|
|
|
export BRANCH_SLUG=$(slugify $BRANCH)
|
2020-06-19 17:38:55 +00:00
|
|
|
|
|
|
|
export CI_REGISTRY="docker.io"
|
|
|
|
export CI_TAG="${COMMIT}-ci"
|
|
|
|
export CI_IMAGE_REPO="${CI_REGISTRY}/${IMAGE}"
|
|
|
|
export CI_IMAGE_URI="${CI_IMAGE_REPO}:${CI_TAG}"
|
|
|
|
|
|
|
|
function TagAndPushImage() {
|
|
|
|
REPO="$1"
|
|
|
|
TAG="$2"
|
|
|
|
|
|
|
|
IMAGE_URI="${REPO}:${TAG}${TAG_SUFFIX}";
|
|
|
|
sudo docker tag ${CI_IMAGE_URI} ${IMAGE_URI};
|
|
|
|
echo " push ${IMAGE_URI}";
|
|
|
|
sudo docker push ${IMAGE_URI};
|
|
|
|
}
|