From 6f6d6e809e648d81db058b3d69c019eee1a6e263 Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Tue, 4 Jun 2019 12:18:31 +0200 Subject: [PATCH] Update .gitlab-ci.yml --- .gitlab-ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2305683..69d8aea 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,10 +1,42 @@ -build: - image: docker:latest - script: - - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - - docker build --pull -t $CI_REGISTRY_IMAGE . - - docker push $CI_REGISTRY_IMAGE - services: +image: docker:latest + +services: - docker:dind + +stages: + - build + - push + +before_script: + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + +Build: + script: + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + - docker build --pull -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA . + - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA + stage: build tags: - - docker \ No newline at end of file + - docker + +Push latest: + only: + - master + script: + - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA + - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest + - docker push $CI_REGISTRY_IMAGE:latest + stage: push + tags: + - docker + +Push tag: + only: + - tags + script: + - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA + - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME + - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME + stage: push + tags: + - docker