Commit c96925a3 authored by nimrod's avatar nimrod
Browse files

Docker Hub template.

Build and push an image to Docker Hub. Match the image tag to the
branch.
parent eecb6e44
Loading
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
---
.hub-build:
  image: docker:19.03
  stage: build
  only:
    - branches
  variables:
    DOCKER_BUILDKIT: "1"
  before_script:
    - &tag |-
      if [ "$CI_COMMIT_BRANCH" = 'master' ]
      then
        TAG='latest'
      else
        TAG="$CI_COMMIT_BRANCH"
      fi
  script:
    - docker build -t "adarnimrod/$IMAGE:$TAG" ./

.hub-push:
  image: docker:19.03
  stage: deploy
  only:
    - branches
  before_script:
    - *tag
    - docker login --username adarnimrod --password "$DOCKER_HUB_TOKEN"
  script:
    - docker push "adarnimrod/$IMAGE:$TAG"

dummy:
  stage: .post
  script:
    - !!str true
  rules:
    - when: never