version: '2'
vars:
  registry: fh1-harbor01.dun.fh
  image: findmypast/usher

tasks:
  hello:
    do: shell
    command: echo Hello world

  build:
    description: build the docker image
    do: shell
    command: docker build --force-rm -t <%=registry%>/<%=image%> .

  push:
    description: push the docker image to the registry
    do: shell
    command: docker push <%=registry%>/<%=image%>

  test:
    description: run unit tests (in container)
    do: shell
    command: docker run --name usher-test-runner --rm <%=registry%>/<%=image%> npm run test:ci

  publish:
    description: publish package to npm
    do: shell
    command: docker run -e NPM_USER -e NPM_TOKEN -e NPM_EMAIL --name usher-publisher --rm <%=registry%>/<%=image%> ./publish.sh
    env:
      NPM_USER: <%=user%>
      NPM_TOKEN: <%=token%>
      NPM_EMAIL: <%=email%>