-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-push.sh
More file actions
executable file
·33 lines (27 loc) · 1.19 KB
/
Copy pathdocker-push.sh
File metadata and controls
executable file
·33 lines (27 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh -e
DISTRO=$1
for architecture in $ARCHS; do
# Retrieve variables from former docker-build.sh
# shellcheck source=/dev/null
. ./"${architecture}"-"${DISTRO}".conf
if [ -n "$CI_JOB_TOKEN" ]; then
#echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
docker pull "$CI_REGISTRY_IMAGE/${IMAGE:=}:$TAG"
#DOCKER_HUB_REGISTRY="docker.io"
#echo "$DOCKER_HUB_ACCESS_TOKEN" | docker login -u "$DOCKER_HUB_USER" --password-stdin "$DOCKER_HUB_REGISTRY"
docker tag "$CI_REGISTRY_IMAGE/${IMAGE}:$TAG" "$DOCKER_HUB_ORGANIZATION/${IMAGE}:$architecture"
docker push "$DOCKER_HUB_ORGANIZATION/${IMAGE}:$architecture"
docker rmi "$CI_REGISTRY_IMAGE/${IMAGE}:$TAG"
else
docker tag "$CI_REGISTRY_IMAGE/$IMAGE:$TAG" "$CI_REGISTRY_IMAGE/$IMAGE:latest"
fi
done
if [ -n "$CI_JOB_TOKEN" ]; then
IMAGES=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep "$DOCKER_HUB_ORGANIZATION" | tr '\n' ' ')
# shellcheck disable=SC2086
docker manifest create "$DOCKER_HUB_ORGANIZATION/${IMAGE}:latest" $IMAGES
docker manifest push -p "docker.io/$DOCKER_HUB_ORGANIZATION/${IMAGE}:latest"
for img in $IMAGES; do
docker rmi "$img"
done
fi