diff options
author | Pete Johanson <peter@peterjohanson.com> | 2020-05-11 11:38:04 -0400 |
---|---|---|
committer | Pete Johanson <peter@peterjohanson.com> | 2020-05-11 11:38:04 -0400 |
commit | c5e4eea3fdc21786f78337c69d03f74252bfbaf5 (patch) | |
tree | 621598c0ae6841b7a71e6dc0453cf5938817bf6d | |
parent | b67c479f701806043b57bfab69a17b7e5b54a584 (diff) |
Tweaks to when we do docker job.
-rw-r--r-- | .gitlab-ci.yml | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d64a147..5477dc7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,11 +22,16 @@ build:dockerimage: image: docker:stable + rules: + - if: '$CI_COMMIT_REF_SLUG =~ /^docker/' + when: always before_script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY script: - docker pull $CI_BUILD_IMAGE:latest || true - - docker build --cache-from $CI_BUILD_IMAGE:latest -t $CI_BUILD_IMAGE:latest . - - docker push $CI_BUILD_IMAGE:latest + - docker build --cache-from $CI_BUILD_IMAGE:latest -t $CI_BUILD_IMAGE:$CI_COMMIT_SHORT_SHA . + - docker push $CI_BUILD_IMAGE:$CI_COMMIT_SHORT_SHA + - docker tag $CI_BUILD_IMAGE:$CI_COMMIT_SHORT_SHA $CI_BUILD_IMAGE:latest && git push $CI_BUILD_IMAGE:latest + - if [ -n "$CI_COMMIT_TAG" ]; then docker tag $CI_BUILD_IMAGE:$CI_COMMIT_SHORT_SHA $CI_BUILD_IMAGE:$CI_COMMIT_TAG && docker push $CI_BUILD_IMAGE:$CI_COMMIT_TAG; fi |