kind: pipeline
type: kubernetes
name: Container image

steps:
- name: Build & publish (Harbor)
  depends_on:
  - clone
  image: plugins/docker
  context: .
  settings:
    repo: bv11-cr01.bessems.eu/library/json-server
    registry: bv11-cr01.bessems.eu
    tags: latest
    mtu: 1450
    username:
      from_secret: harbor_username
    password:
      from_secret: harbor_password
- name: Build & publish (Dockerhub)
  depends_on:
  - clone
  image: plugins/docker
  context: .
  settings:
    repo: djpbessems/json-server
    tags: latest
    mtu: 1450
    username:
      from_secret: docker_username
    password:
      from_secret: docker_password

---
kind: pipeline
type: kubernetes
name: Helm chart (Gitea)

steps:
- name: Package & publish
  image: bv11-cr01.bessems.eu/proxy/alpine/helm
  commands:
  - |
    apk add yq
  - |
    helm package ./charts/json-server
  - |
    CHART_VERSION=$(cat ./charts/json-server/Chart.yaml | yq '.version')
    curl \
      --header "Authorization: token $GIT_APIKEY" \
      --upload-file json-server-$CHART_VERSION.tgz \
      https://code.spamasaurus.com/api/packages/$GIT_USERNAME/generic/json-server/$CHART_VERSION/json-server-$CHART_VERSION.tgz
  environment:
    GIT_APIKEY:
      from_secret: git_apikey
    GIT_USERNAME: djpbessems