added drone/HelmChart templates
This commit is contained in:
parent
349ec20e4b
commit
7028d08307
78
drone/HelmChart.yml
Normal file
78
drone/HelmChart.yml
Normal file
@ -0,0 +1,78 @@
|
||||
.HelmChartLint: &HelmChartLint
|
||||
name: HelmChartLint
|
||||
image: alpine/helm:3.10.0
|
||||
|
||||
environment:
|
||||
CHART_PATH: "./chart"
|
||||
|
||||
commands:
|
||||
- |
|
||||
cd "$CHART_PATH"
|
||||
helm lint .
|
||||
|
||||
.HelmChartPublish: &HelmChartPublish
|
||||
name: HelmChartPublish
|
||||
image: alpine/helm:3.10.0
|
||||
|
||||
environment:
|
||||
HELM_REPO_NAME: "" # defaults to project name
|
||||
HELM_ENDPOINT: "" # defaults to gitea organization helm registry if running in gitea
|
||||
HELM_USER: "" # defaults to CI_REGISTRY_USER
|
||||
HELM_PASSWORD: "" # defaults to CI_REGISTRY_PASSWORD
|
||||
|
||||
CHART_PATH: "./chart"
|
||||
|
||||
TAG_COMMIT_ENABLE: "true"
|
||||
TAG_COMMIT_BASE_VERSION: "0.0.0"
|
||||
TAG_COMMIT_PREFIX: "commit-"
|
||||
|
||||
TAG_REF_SLUG_ENABLE: "true"
|
||||
TAG_REF_SLUG_BASE_VERSION: "0.0.0"
|
||||
|
||||
commands:
|
||||
# drone does not support expanding vars in environment values, set defaults via bash
|
||||
- if [[ -z "$HELM_REPO_NAME" ]]; then HELM_REPO_NAME=$CI_PROJECT_NAME; fi
|
||||
- if [[ -z "$HELM_USER" ]]; then HELM_USER=$CI_REGISTRY_USER; fi
|
||||
- if [[ -z "$HELM_PASSWORD" ]]; then HELM_PASSWORD=$CI_REGISTRY_PASSWORD; fi
|
||||
|
||||
# add default chart endpoints for gitea
|
||||
- |
|
||||
if [[ -z "$HELM_ENDPOINT" ]]; then
|
||||
if [[ ! -z "$GITEA_PACKAGES_API" ]]; then
|
||||
HELM_ENDPOINT="$GITEA_PACKAGES_API/$CI_PROJECT_NAMESPACE/helm"
|
||||
else
|
||||
echo "ERROR: no helm endpoint defined"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# install plugin chartmuseum/helm-push
|
||||
- helm plugin install https://github.com/chartmuseum/helm-push
|
||||
|
||||
# register repo
|
||||
- helm repo add --username="$HELM_USER" --password="$HELM_PASSWORD" "$HELM_REPO_NAME" "$HELM_ENDPOINT"
|
||||
|
||||
# prepare package
|
||||
- |
|
||||
cd "$CHART_PATH"
|
||||
helm package .
|
||||
|
||||
- |
|
||||
if [[ "$GITLAB_HELM_REPO_AUTH" == "true" ]]; then
|
||||
helm repo add --username="${CI_REGISTRY_USER}" --password="${CI_REGISTRY_PASSWORD}" "$HELM_REPO_NAME" $HELM_STABLE_ENDPOINT
|
||||
fi
|
||||
|
||||
# default tag based on commit
|
||||
- |
|
||||
if [[ "$TAG_COMMIT_ENABLE" == "true" ]]; then
|
||||
helm cm-push . "$HELM_REPO_NAME" --version=$TAG_COMMIT_BASE_VERSION-$IMAGE_COMMIT_PREFIX-$CI_COMMIT_SHA
|
||||
fi
|
||||
|
||||
# add tag for reference if available
|
||||
- |
|
||||
if [[ "$TAG_REF_SLUG_ENABLE" == "true" ]] && [[ ! -z $DRONE_TAG ]]; then
|
||||
# special handling for tags: strip leading "v" character if present to allow tags with or without leading "v" to work
|
||||
helm cm-push . "$HELM_REPO_NAME" --version="${DRONE_TAG#"v"}"
|
||||
elif [[ "$TAG_REF_SLUG_ENABLE" == "true" ]] && [[ -z "$DRONE_PULL_REQUEST" ]] && [[ ! -z $DRONE_BRANCH ]]; then
|
||||
helm cm-push . "$HELM_REPO_NAME" --version=$TAG_REF_SLUG_BASE_VERSION-$DRONE_BRANCH
|
||||
fi
|
||||
Loading…
Reference in New Issue
Block a user