Verified Commit de47aea4 authored by Maarten de Waard's avatar Maarten de Waard
Browse files

publish helm chart to package registry

parent 1cd9374b
Pipeline #10321 passed with stages
in 1 minute and 40 seconds
# Default image for helm-related jobs
image:
name: alpine/helm:3.7.1
entrypoint: ["/bin/sh", "-c"]
stages:
- build-project
- build-container
- lint-helm-chart
- package-helm-chart
- release-helm-chart
variables:
KANIKO_BUILD_IMAGENAME: local-path-provisioner
......@@ -27,3 +36,51 @@ build-container:
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --cache=true --context ${CI_PROJECT_DIR}/ --dockerfile ${CI_PROJECT_DIR}/package/Dockerfile --destination ${CI_REGISTRY_IMAGE}/${KANIKO_BUILD_IMAGENAME}:${CI_COMMIT_REF_NAME}
# Only package a new chart once the version number has been updated
.chart_release_rules:
rules:
- changes:
- deploy/chart/Chart.yaml
lint-helm:
stage: lint-helm-chart
script:
- cd deploy/chart
- helm dep update
- helm lint .
artifacts:
paths:
- 'deploy/chart/charts/**'
expire_in: 1 week
# Even if lint fails, upload the charts/ folder as artifact
rules:
- changes:
- 'deploy/chart/*.yaml'
- deploy/chart/templates/*.yaml
package-chart:
stage: package-helm-chart
script:
- cd deploy/chart
- helm package .
artifacts:
paths:
- deploy/chart/local-path-provisioner-*
expire_in: 1 week
extends:
- .chart_release_rules
# Push helm chart. Charts on the `main` branch are pushed to `stable`, others
# are pushed to the `unstable` channel.
release-helm:
image: "rancher/curlimages-curl:7.73.0"
stage: release-helm-chart
script:
- cd deploy/chart
- if [ "$CI_COMMIT_BRANCH" == "main" ]; then export HELM_CHANNEL='stable'; else export HELM_CHANNEL='unstable'; fi
- export CHART_FILE=$(ls local-path-provisioner-*.tgz)
- curl --fail --request POST --user gitlab-ci-token:$CI_JOB_TOKEN --form "chart=@${CHART_FILE}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/api/${HELM_CHANNEL}/charts"
extends:
- .chart_release_rules
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment