-
Notifications
You must be signed in to change notification settings - Fork 30
/
push
executable file
·35 lines (29 loc) · 1.41 KB
/
push
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
34
35
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
export DEPLOY_ROOT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
source "$DEPLOY_ROOT_DIR/src/common.bash"
if [[ -n "$CI_REGISTRY_USER" ]]; then
echo "Logging to GitLab Container Registry with CI credentials..."
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
echo ""
fi
echo "Tagging application as latest..."
if [ "x$1" != "x" ]; then
echo "Tagging $CI_REGISTRY_IMAGE:$SHORT-$CI_REGISTRY_TAG as $CI_REGISTRY_IMAGE:$SHORT-latest"
export SHORT=$(echo "$1" | cut -d'-' -f2-)
docker pull $CI_REGISTRY_IMAGE:$SHORT-$CI_REGISTRY_TAG
docker tag $CI_REGISTRY_IMAGE:$SHORT-$CI_REGISTRY_TAG $CI_REGISTRY_IMAGE:$SHORT-latest
echo "Pushing to GitLab Container Registry..."
docker push $CI_REGISTRY_IMAGE:$SHORT-latest
else
echo "Tagging $CI_REGISTRY_IMAGE:$CI_REGISTRY_TAG as $CI_REGISTRY_IMAGE:latest"
docker pull $CI_REGISTRY_IMAGE:$CI_REGISTRY_TAG
docker tag $CI_REGISTRY_IMAGE:$CI_REGISTRY_TAG $CI_REGISTRY_IMAGE:latest
echo "Pushing to GitLab Container Registry..."
docker push "$CI_REGISTRY_IMAGE:latest"
fi