image: node:latest

stages:
  - build
  - test
  - deploy

cache:
  paths:
    - smart-hut/node_modules/

install_dependencies:
  stage: build
  script:
    - cd smart-hut
    - yarn install
  artifacts:
    paths:
      - smart-hut/node_modules/

testing_testing:
  stage: test
  script:
    - cd smart-hut
    - yarn test

smartHut_deploy:
  stage: deploy
  tags:
    - dind
  image: docker:latest
  services:
    - docker:dind
  variables:
    DOCKER_DRIVER: overlay
  before_script:
    - docker version
    - docker info
    - docker login -u smarthutsm -p $CI_DOCKER_PASS #GiovanniRoberto
  script:
    - "docker build -t smarthutsm/smarthut:${CI_COMMIT_BRANCH} ."
    - "docker push smarthutsm/smarthut:${CI_COMMIT_BRANCH}"
  after_script:
    - docker logout
  only:
    - dev
    - master
