kind: pipeline
name: main-pipeline
platform:
  os: linux
  arch: amd64

steps:
- name: build-ui
  image: node:16.13-slim
  volumes:
  - name: temp
    path: /app
  commands:
  - apt-get update
  - apt-get -y install libssl-dev
  - npm install
  - npm run build
  - cp -R ./dist /app/dist

- name: test
  image: rust
  volumes:
  - name: temp
    path: /app
  commands:
  - cp -R /app/dist ./dist
  - cargo test

- name: build
  image: rust
  volumes:
  - name: temp
    path: /app
  commands:
  - cp -R /app/dist ./dist
  - rustup target add x86_64-unknown-linux-musl
  - apt update && apt install -y musl-tools musl-dev
  - update-ca-certificates
  - cargo build --target x86_64-unknown-linux-musl --release
  - mkdir /app/build
  - cp target/x86_64-unknown-linux-musl/release/vade /app/build/vade
  # when:
  #   event:
  #     - promote

- name: stage-deploy  
  image: plugins/docker
  privileged: true
  volumes:
  - name: temp
    path: /app
  settings:
    username:
      from_secret: CONTAINER_USER
    password:
      from_secret: CONTAINER_PASSWORD
    registry: git.5sigma.io
    context: /app/build
    repo: git.5sigma.io/vade/app
    tags: latest
  # when:
  #   event:
  #     - promote
  #   target:
  #     - staging
  #     - production

volumes:
- name: temp
  temp: {}
