-
Notifications
You must be signed in to change notification settings - Fork 2k
/
docker.sh
executable file
·26 lines (21 loc) · 740 Bytes
/
docker.sh
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
#! /bin/bash
git_commit=$1
git_tag=$2
docker_tag=edge
commit_tag=$(git tag --contains ${git_commit})
if [[ ${commit_tag} == *${git_tag}* ]]; then
# we're on the tag, use the docker image for the tag
docker_tag=${git_tag//v/}
echo ${docker_tag}
exit 0
else
# we're on main or a branch, try to download the latest edge and see if sha matches
docker pull nginx/nginx-ingress:${docker_tag} >/dev/null 2>&1
DOCKER_SHA=$(docker inspect --format '{{ index .Config.Labels "org.opencontainers.image.revision" }}' nginx/nginx-ingress:${docker_tag})
if [[ ${DOCKER_SHA} == ${git_commit} ]]; then
# we're on the same commit as the latest edge
echo ${docker_tag}
exit 0
fi
fi
echo "fail"