#!/usr/bin/env bash

set -e

if [[ "${TRAVIS}" == "true" ]];
then
  if [[ ! -n "${HEROKU_TOKEN}" ]];
  then
    echo "Please define the variable HEROKU_TOKEN to autodeploy in Heroku"
    exit 1
  fi
  docker login --email=_ --username=_ --password=${HEROKU_TOKEN} registry.heroku.com
fi

application_name=oneclick-api-integration
docker build --build-arg NPM_TOKEN=${NPM_TOKEN} -t ${application_name} -f Dockerfile .
docker tag ${application_name} registry.heroku.com/${application_name}/web
docker push registry.heroku.com/${application_name}/web


