kind: pipeline
type: docker
name: ui

steps:
- name: build-ui
  image: node:12.7.0
  volumes:
  - name: build
    path: /build/
  commands:
  - cd client
  - yarn install
  - yarn check
  - yarn test:ci
  - yarn build
  - mv build/* /build/
  when:
    branch:
    - master
- name: publish-ui
  image: appleboy/drone-scp
  volumes:
  - name: build
    path: /build/
  when:
    branch:
    - master
  settings:
    host: hiram.services
    username: hiram
    key:
      from_secret: ssh_key
    port: 355
    target: "/opt/terrassumptions/srv/build-last-push"
    source: /build
- name: deploy-ui
  image: appleboy/drone-ssh
  when:
    branch:
    - master
  settings:
    host: hiram.services
    username: hiram
    key:
      from_secret: ssh_key
    port: 355
    script:
    - cd /opt/terrassumptions/srv/
    - ./update.sh
    
volumes:
- name: build
  temp: {}

---
kind: pipeline
type: docker
name: server

steps:
- name: publish-server  
  image: plugins/docker
  settings:
    context: ./server
    dockerfile: ./server/Dockerfile
    username: 
        from_secret: registry_username
    password: 
        from_secret: registry_password
    repo: registry.hiram.services/terrassumptions-server
    tags: latest
    registry: registry.hiram.services
  when:
    branch:
    - master