---
kind: secret
name: docker_username
get:
  path: odit-registry-builder
  name: username

---
kind: secret
name: docker_password
get:
  path: odit-registry-builder
  name: password

---
kind: secret
name: git_ssh
get:
  path: odit-git-bot
  name: sshkey

---
kind: pipeline
type: kubernetes
name: tests:node
clone:
  disable: true
steps:
  - name: checkout pr
    image: alpine/git
    commands:
      - git clone $DRONE_REMOTE_URL .
      - git checkout $DRONE_SOURCE_BRANCH
  - name: run tests
    image: registry.odit.services/hub/library/node:19.0.1-alpine3.16
    commands:
      - yarn
      - yarn test:ci
trigger:
  event:
    - pull_request

---
kind: pipeline
type: kubernetes
name: build:dev
clone:
  disable: true

steps:
  - name: clone
    image: alpine/git
    commands:
      - git clone $DRONE_REMOTE_URL .
      - git checkout dev
  - name: build dev
    image: registry.odit.services/library/drone-kaniko
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      build_args:
        - NPM_REGISTRY_DOMAIN:
          from_secret: npmjs_domain
        - NPM_REGISTRY_TOKEN:
          from_secret: npmjs_token
      repo: lfk/mailer
      tags:
        - dev
      cache: true
      registry: registry.odit.services
trigger:
  branch:
    - dev
  event:
    - push

---
kind: pipeline
type: kubernetes
name: build:latest
clone:
  disable: true

steps:
  - name: clone
    image: alpine/git
    commands:
      - git clone $DRONE_REMOTE_URL .
      - git checkout dev
      - git merge main
      - git checkout main
  - name: build latest
    image: registry.odit.services/library/drone-kaniko
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      build_args:
        - NPM_REGISTRY_DOMAIN:
          from_secret: npmjs_domain
        - NPM_REGISTRY_TOKEN:
          from_secret: npmjs_token
      repo: lfk/mailer
      tags:
        - latest
      cache: true
      registry: registry.odit.services
trigger:
  branch:
    - main
  event:
    - push

---
kind: pipeline
type: kubernetes
name: build:tags

steps:
  - name: build $DRONE_TAG
    image: registry.odit.services/library/drone-kaniko
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      build_args:
        - NPM_REGISTRY_DOMAIN:
          from_secret: npmjs_domain
        - NPM_REGISTRY_TOKEN:
          from_secret: npmjs_token
      repo: lfk/mailer
      tags:
        - "${DRONE_TAG}"
      cache: true
      registry: registry.odit.services
trigger:
  event:
    - tag
