33# Copyright 2016-2020, Intel Corporation
44
55#
6- # push-image.sh - pushes the Docker image tagged with OS-VER to the Docker Hub .
6+ # push-image.sh - pushes the Docker image tagged with OS-VER to the ${CONTAINER_REG} .
77#
8- # The script utilizes $DOCKERHUB_USER and $DOCKERHUB_PASSWORD variables to
9- # log in to the Docker Hub . The variables can be set in the CI's configuration
8+ # The script utilizes ${CONTAINER_REG_USER} and ${ DOCKERHUB_PASSWORD} variables to
9+ # log in to the ${CONTAINER_REG} . The variables can be set in the CI's configuration
1010# for automated builds.
1111#
1212
@@ -22,23 +22,29 @@ if [[ -z "${OS_VER}" ]]; then
2222 exit 1
2323fi
2424
25- if [[ -z " ${DOCKERHUB_REPO} " ]]; then
26- echo " DOCKERHUB_REPO environment variable is not set"
25+ if [[ -z " ${CONTAINER_REG} " ]]; then
26+ echo " CONTAINER_REG environment variable is not set"
27+ exit 1
28+ fi
29+
30+ if [[ -z " ${CONTAINER_REG_USER} " || -z " ${CONTAINER_REG_PASS} " ]]; then
31+ echo " ERROR: variables CONTAINER_REG_USER=\" ${CONTAINER_REG_USER} \" and CONTAINER_REG_PASS=\" ${CONTAINER_REG_PASS} \" " \
32+ " have to be set properly to allow login to the Container Registry."
2733 exit 1
2834fi
2935
3036TAG=" 1.12-${OS} -${OS_VER} "
3137
32- echo " Check if the image tagged with ${DOCKERHUB_REPO } :${TAG} exists locally"
33- if [[ ! $( docker images -a | awk -v pattern=" ^${DOCKERHUB_REPO } :${TAG} \$ " \
38+ echo " Check if the image tagged with ${CONTAINER_REG } :${TAG} exists locally"
39+ if [[ ! $( docker images -a | awk -v pattern=" ^${CONTAINER_REG } :${TAG} \$ " \
3440 ' $1":"$2 ~ pattern' ) ]]
3541then
36- echo " ERROR: Docker image tagged ${DOCKERHUB_REPO } :${TAG} does not exist locally."
42+ echo " ERROR: Docker image tagged ${CONTAINER_REG } :${TAG} does not exist locally."
3743 exit 1
3844fi
3945
40- echo " Log in to the Docker Hub "
41- docker login -u= " ${DOCKERHUB_USER } " -p =" ${DOCKERHUB_PASSWORD} "
46+ echo " Log in to the container registry "
47+ echo " ${CONTAINER_REG_PASS } " | docker login ghcr.io -u =" ${CONTAINER_REG_USER} " --password-stdin
4248
43- echo " Push the image to the repository "
44- docker push ${DOCKERHUB_REPO } :${TAG}
49+ echo " Push the image to the container registry "
50+ docker push ${CONTAINER_REG } :${TAG}
0 commit comments