build docker image:
  image: docker:latest
  script:
    - docker build --pull -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG} .
    - docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
    - docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}
  stage: build
  needs: []
  tags:
    - docker

upload Helm Chart:
  stage: build
  image: alpine/helm:3.2.4
  rules:
    - if: $CI_MERGE_REQUEST_ID
      when: never
    - if: '$CI_COMMIT_REF_SLUG =~ /(master|develop)/'
      changes:
        - helm/**/*
      when: on_success
  script:
    - apk add --update --no-cache curl
    - helm package helm/user-guide
    - curl --data-binary "@$(ls user-guide-*.tgz)" -s http://charts-chartmuseum.chartmuseum.svc.cluster.local:8080/api/charts
  tags:
    - kubernetes