Debian Codegraph @

src/deps/miniasync/utils/docker/images/push-image.sh

raw
1 #!/usr/bin/env bash
2 #
3 # SPDX-License-Identifier: BSD-3-Clause
4 # Copyright 2016-2020, Intel Corporation
5 #
6
7 #
8 # push-image.sh - pushes the Docker image to ${DOCKER_REPO}
9 #
10 # The script utilizes $GH_CR_USER and $GH_CR_PAT variables
11 # to log in to ${DOCKER_REPO}. The variables can be set
12 # in the CI project's configuration for automated builds.
13 #
14
15 set -e
16
17 source $(dirname $0)/../set-ci-vars.sh
18
19 if [[ -z "$OS" ]]; then
20 echo "OS environment variable is not set"
21 exit 1
22 fi
23
24 if [[ -z "$OS_VER" ]]; then
25 echo "OS_VER environment variable is not set"
26 exit 1
27 fi
28
29 if [[ -z "${DOCKER_REPO}" ]]; then
30 echo "DOCKER_REPO environment variable is not set"
31 exit 1
32 fi
33
34 if [[ -z "${GH_CR_USER}" || -z "${GH_CR_PAT}" ]]; then
35 echo "ERROR: variables GH_CR_USER=\"${GH_CR_USER}\" and GH_CR_PAT=\"${GH_CR_PAT}\"" \
36 "have to be set properly to allow login to the ${DOCKER_REPO}."
37 exit 1
38 fi
39
40 TAG="${IMG_VER}-${OS}-${OS_VER}"
41
42 # Check if the image tagged with ${DOCKER_REPO}:${TAG} exists locally
43 if [[ ! $(docker images -a | awk -v pattern="^${DOCKER_REPO}:${TAG}\$" \
44 '$1":"$2 ~ pattern') ]]
45 then
46 echo "ERROR: Docker image tagged ${DOCKER_REPO}:${TAG} does not exists locally."
47 exit 1
48 fi
49
50 # Log in to ${DOCKER_REPO}
51 echo "${GH_CR_PAT}" | docker login ${GH_CR_ADDR} -u="${GH_CR_USER}" --password-stdin
52
53 # Push the image to ${DOCKER_REPO}
54 docker push ${DOCKER_REPO}:${TAG}