kind: pipeline
type: kubernetes
name: build-backstage

steps:
  - name: build-backend
    image: node:18-bookworm
    commands:
      - corepack enable
      - yarn install --immutable
      - yarn tsc
      - yarn build:backend

  - name: docker-build-push
    image: gcr.io/kaniko-project/executor:debug
    environment:
      HARBOR_USERNAME:
        from_secret: harbor_username
      HARBOR_PASSWORD:
        from_secret: harbor_password
    commands:
      - echo "{\"auths\":{\"registre.rber.bj\":{\"username\":\"$HARBOR_USERNAME\",\"password\":\"$HARBOR_PASSWORD\"}}}" > /kaniko/.docker/config.json
      - /kaniko/executor --context=/drone/src --dockerfile=/drone/src/packages/backend/Dockerfile --destination=registre.rber.bj/rber/backstage:v0.1.0 --destination=registre.rber.bj/rber/backstage:latest

trigger:
  branch:
    - main
  event:
    - push
