---
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: build:dev

steps:
  - name: run full license export
    depends_on: ["clone"]
    image: registry.odit.services/hub/library/node:19.7.0-alpine3.16
    commands:
      - npm config set registry http://npm-cache.drone.svc.cluster.local:8080 && npm i -g pnpm
      - pnpm i
      - pnpm licenses:export
  - name: push new licenses file to repo
    depends_on: ["run full license export"]
    image: appleboy/drone-git-push
    settings:
      branch: dev
      commit: true
      commit_message: new license file version [CI SKIP]
      author_email: bot@odit.services
      remote: git@git.odit.services:lfk/frontend.git
      ssh_key:
        from_secret: git_ssh
  - name: build dev
    depends_on: ["clone"]
    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/frontend
      tags:
        - dev
      cache: true
      registry: registry.odit.services
trigger:
  branch:
    - dev
  event:
    - push

---
kind: pipeline
type: kubernetes
name: build:tags
steps:
  - name: build $DRONE_TAG
    depends_on: ["clone"]
    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/frontend
      tags:
        - "${DRONE_TAG}"
      cache: true
      registry: registry.odit.services
trigger:
  event:
  - tag