From 8fbce56d694be9eaf5700af627d8b89576cc98ac Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Mon, 12 Nov 2018 15:22:18 +0200 Subject: [PATCH] CI: Change the push policy of the docker images If we are in a fork of the project, we would like to be able to overwrite the `:latest` tag if the registry from any branch so we won't have to manually overwrite the image tag in the build/test jobs in the .gitlab-ci.yml file --- .gitlab-ci.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a3ab7814d1..ba7b3cba1a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,9 +40,17 @@ test manifest: - docker build --pull -f ${DOCKERFILE} -t ${REF} ${CONTEXT_DIR} - docker image tag ${REF} ${LATEST} - # Push the images + # If we are in a fork, push the image to the reigstry regardless the branch - | - if [ "$CI_COMMIT_REF_NAME" = "master" ]; then + 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" && "$CI_PROJECT_NAMESPACE" = "gstreamer" ]; then docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY docker push ${REF} docker push ${LATEST}