Skip to content

Commit 23886c4

Browse files
authored
Merge pull request #3107 from sombraSoft/push-latest-tag
Added latest tag when pushing docker images
2 parents 9c1f98e + a9e35b8 commit 23886c4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

etc/DockerHelper.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ usage: $0 [CMD] [OPTIONS]
3333
-password=PASSWORD Password to loging at the docker registry.
3434
-ci Install CI tools in image
3535
-dry-run Do not push images to the repository
36+
-push-latest Push the latest image to the repository
3637
-no-constant-build-dir Do not use constant build directory
3738
-h -help Show this message and exits
3839
@@ -136,10 +137,22 @@ _push() {
136137
orfsTag=${org}/orfs:${tag}
137138
echo "Renaming docker image: ${builderTag} -> ${orfsTag}"
138139
${DOCKER_CMD} tag ${builderTag} ${orfsTag}
140+
139141
if [[ "${dryRun}" == 1 ]]; then
140142
echo "[DRY-RUN] ${DOCKER_CMD} push ${orfsTag}"
143+
if [[ "${pushLatest}" == 1 ]]; then
144+
echo "[DRY-RUN] ${DOCKER_CMD} tag ${orfsTag} \"${org}/orfs:latest\""
145+
echo "[DRY-RUN] ${DOCKER_CMD} push \"${org}/orfs:latest\""
146+
fi
141147
else
142148
${DOCKER_CMD} push ${orfsTag}
149+
150+
# Only tag and push as latest if requested
151+
if [[ "${pushLatest}" == 1 ]]; then
152+
${DOCKER_CMD} tag ${orfsTag} "${org}/orfs:latest"
153+
${DOCKER_CMD} push "${org}/orfs:latest"
154+
echo "Tagged and pushed ${org}/orfs:latest"
155+
fi
143156
fi
144157
fi
145158
}
@@ -174,6 +187,7 @@ numThreads="-1"
174187
tag=""
175188
options=""
176189
dryRun=0
190+
pushLatest=0
177191

178192
while [ "$#" -gt 0 ]; do
179193
case "${1}" in
@@ -186,6 +200,9 @@ while [ "$#" -gt 0 ]; do
186200
-dry-run )
187201
dryRun=1
188202
;;
203+
-push-latest )
204+
pushLatest=1
205+
;;
189206
-os=* )
190207
os="${1#*=}"
191208
;;

0 commit comments

Comments
 (0)