stages:
  - build
  - deploy

build-docker-image:
  stage: build
  script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    - docker build --pull -t "$CI_REGISTRY_IMAGE" .
    - docker push "$CI_REGISTRY_IMAGE"
  only:
    - master
    - chat
  except:
    - schedules

update-docker-image:
  stage: deploy
  tags:
    - ansible-update
  variables:
    GIT_STRATEGY: none
  script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    - docker pull "$CI_REGISTRY_IMAGE"
  only:
    - master
    - chat
  except:
    - schedules
