9
9
# what tag, if any, to push to dockerhub.
10
10
#
11
11
# Usage:
12
- # ./push-docker-tags.sh <image name> <git commit sha1> <git branch name> [git tag name] [dry run]
12
+ # ./push-docker-tags.sh <image name> <git commit sha1> [git tag name] [dry run]
13
13
#
14
14
# Example:
15
15
# # dry run. pass a 5th arg to have it print what it would do rather than do it.
16
- # ./push-docker-tags.sh myiamge testingsha master "" dryrun
16
+ # ./push-docker-tags.sh myiamge testingsha "" dryrun
17
17
#
18
18
# # push tag for commit on the main branch
19
- # ./push-docker-tags.sh myimage testingsha main
19
+ # ./push-docker-tags.sh myimage testingsha
20
20
#
21
21
# # push tag for a new release tag
22
- # ./push-docker-tags.sh myimage testingsha release v0.5.0
22
+ # ./push-docker-tags.sh myimage testingsha v0.5.0
23
23
#
24
24
# # serving suggestion in circle ci - https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
25
- # ./push-docker-tags.sh filecoin/sentinel-visor $CIRCLE_SHA1 $CIRCLE_BRANCH $ CIRCLE_TAG
25
+ # ./push-docker-tags.sh filecoin/sentinel-visor $CIRCLE_SHA1 $CIRCLE_TAG
26
26
#
27
27
set -euo pipefail
28
28
29
- if [[ $# -lt 3 ]] ; then
30
- echo ' At least 3 args required. Pass 5 args for a dry run.'
29
+ if [[ $# -lt 2 ]] ; then
30
+ echo ' At least 2 args required. Pass 4 args for a dry run.'
31
31
echo ' Usage:'
32
- echo ' ./push-docker-tags.sh <image name> <git commit sha1> <git branch name> [git tag name] [dry run]'
32
+ echo ' ./push-docker-tags.sh <image name> <git commit sha1> [git tag name] [dry run]'
33
33
exit 1
34
34
fi
35
35
36
36
IMAGE_NAME=$1
37
37
GIT_SHA1=$2
38
- GIT_SHA1_SHORT=$( echo " $GIT_SHA1 " | cut -c 1-7)
39
- GIT_BRANCH=$3
40
- GIT_TAG=${4:- " " }
41
- DRY_RUN=${5:- false}
42
- DATE_SHORT=$( date -u +%F)
38
+ GIT_SHA1_SHORT=$( echo " $GIT_SHA1 " | cut -c 1-8)
39
+ GIT_TAG=${3:- " " }
40
+ DRY_RUN=${4:- false}
43
41
44
42
pushTag () {
45
43
local IMAGE_TAG=" ${1/ \/ / -} "
@@ -54,8 +52,8 @@ pushTag () {
54
52
fi
55
53
}
56
54
57
- if [ -z " $GIT_TAG " ]; then
58
- pushTag " $GIT_BRANCH - ${DATE_SHORT } -${GIT_SHA1_SHORT} "
55
+ if [ -z " ${ GIT_TAG} " ]; then
56
+ pushTag " ${GIT_BRANCH } -${GIT_SHA1_SHORT} "
59
57
else
60
- pushTag " $GIT_TAG "
58
+ pushTag " ${ GIT_TAG} "
61
59
fi
0 commit comments