Docker registry: only tag images for the upstream repository
authorJordan Petridis <jordan@centricular.com>
Sat, 24 Nov 2018 22:48:50 +0000 (00:48 +0200)
committerJordan Petridis <jpetridis@gnome.org>
Mon, 26 Nov 2018 12:51:39 +0000 (12:51 +0000)
The tags are only used to version the images that are meant
to be used in the gitlab/ci_template.yml file. Thus tags are
not needed when you hack on a patch from a forked repository.
Lets just keep a :latest tag.

.gitlab-ci.yml

index 52c371c..f076999 100644 (file)
@@ -41,20 +41,21 @@ test manifest:
     - export REF="${IMAGE}:${CI_COMMIT_SHA}"
     - export LATEST="${IMAGE}:latest"
 
-    - docker build --pull -f ${DOCKERFILE} -t ${REF} ${CONTEXT_DIR}
-    - docker image tag ${REF} ${LATEST}
+    - docker build --pull -f ${DOCKERFILE} -t ${LATEST} ${CONTEXT_DIR}
 
     # If we are in a fork, push the image to the reigstry regardless the branch
     - |
       if [ "$CI_PROJECT_NAMESPACE" != "gstreamer" ]; then
         docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
-        docker push ${REF}
         docker push ${LATEST}
       fi
 
     # Push the images to the upstream registry
     - |
       if [ "$CI_COMMIT_REF_NAME" = "master" -a "$CI_PROJECT_NAMESPACE" = "gstreamer" ]; then
+        # Tag the image with the git ref
+        docker image tag ${LATEST} ${REF}
+        # Push the tags
         docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
         docker push ${REF}
         docker push ${LATEST}