diff --git a/README.md b/README.md index 2deaf6c616ce9356f4e91e76493fd03508fa8371..4d2812413ec280f9be613730467c05a40621d2ea 100644 --- a/README.md +++ b/README.md @@ -312,7 +312,7 @@ Here are variables supported to configure the production environment: |Â `HELM_PROD_ENVIRONMENT_URL`| The production environment url _(only define for static environment URLs declaration and if different from default)_ | `$HELM_ENVIRONMENT_URL` | | `HELM_PROD_NAMESPACE` | The Kubernetes namespace to use for `production` env _(only define to override default)_ | `$KUBE_NAMESPACE` | | :lock: `HELM_PROD_KUBE_CONFIG` | Specific kubeconfig for `production` env _(only define to override default)_ | `$HELM_DEFAULT_KUBE_CONFIG` | -| `AUTODEPLOY_TO_PROD` | Set this variable to auto-deploy to production. If not set deployment to production will be `manual` (default behaviour). | _none_ (disabled) | +| `HELM_PROD_DEPLOY_STRATEGY`| Defines the deployment to production strategy. One of `manual` (i.e. _one-click_) or `auto`. | `manual` | | `HELM_PROD_VALUES` | The [Values file](https://helm.sh/docs/chart_template_guide/values_files/) to use with the production environment | _none_ | ### `helm-lint` job @@ -407,6 +407,7 @@ This job publishes the packaged chart to a [chart repository](https://helm.sh/do | :lock: `HELM_PUBLISH_PASSWORD` | Helm registry password | `$CI_REGISTRY_PASSWORD` | | `HELM_PUBLISH_URL` | The URL of the Helm repository to publish your Helm package.<br/>Supports both [chart repository](https://helm.sh/docs/topics/chart_repository/) or [OCI-based registry](https://helm.sh/docs/topics/registries/) (url must be prefixed with `oci://`) | `oci://$CI_REGISTRY/$CI_PROJECT_PATH/charts` ([GitLab's container registry](https://docs.gitlab.com/ee/user/packages/container_registry/)) | | `HELM_PUBLISH_ON` | Defines on which branch(es) the publish job shall be enabled (`prod` to enable on production branch only, `protected` to enable on protected references and `all` to enable on all Git references) | `prod` | +| `HELM_PUBLISH_STRATEGY` | Defines the publish strategy. One of `manual` (i.e. _one-click_), `auto` or `none` (disabled). | `manual` | | `HELM_CM_PUSH_PLUGIN_VERSION` | cm-push plugin version to install (only when using `push` method with a regular chart [repository](https://helm.sh/docs/topics/chart_repository/)) | _none_ (latest) | diff --git a/kicker.json b/kicker.json index b3baf2fe3cc76822a6957dcd0c04b655b620e54d..8a633624e032103be564f7b63bdabad04b31029a 100644 --- a/kicker.json +++ b/kicker.json @@ -219,6 +219,13 @@ "values": ["prod", "protected", "all"] }, { + "name": "HELM_PUBLISH_STRATEGY", + "description": "Defines the publish strategy.", + "type": "enum", + "values": ["none", "manual", "auto"], + "default": "manual" + }, + { "name": "HELM_CM_PUSH_PLUGIN_VERSION", "description": "cm-push plugin version to install (only when using `push` method with a regular chart [repository](https://helm.sh/docs/topics/chart_repository/)", "advanced": true @@ -343,9 +350,11 @@ "enable_with": "HELM_PROD_ENABLED", "variables": [ { - "name": "AUTODEPLOY_TO_PROD", - "type": "boolean", - "description": "Set this variable to auto-deploy to production. If not set deployment to production will be manual (default behaviour)." + "name": "HELM_PROD_DEPLOY_STRATEGY", + "description": "Defines the deployment to production strategy.", + "type": "enum", + "values": ["manual", "auto"], + "default": "manual" }, { "name": "HELM_PROD_APP_NAME", diff --git a/templates/gitlab-ci-helm.yml b/templates/gitlab-ci-helm.yml index d34ea30fe13646bcc512ed806483dd5b2a606db4..d910ed1966f740bbf670091cb4e58ead58d939db 100644 --- a/templates/gitlab-ci-helm.yml +++ b/templates/gitlab-ci-helm.yml @@ -64,7 +64,8 @@ variables: # HELM_PUBLISH_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/release" # HELM_PUBLISH_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/release" HELM_PUBLISH_METHOD: "auto" - + HELM_PUBLISH_STRATEGY: "manual" + HELM_REPOS: "stable@https://charts.helm.sh/stable bitnami@https://charts.bitnami.com/bitnami" HELM_ENV_VALUE_NAME: environmentType @@ -109,6 +110,9 @@ variables: HELM_REVIEW_ENVIRONMENT_SCHEME: "https" HELM_PUBLISH_ON: "prod" + # default: one-click deploy + HELM_PROD_DEPLOY_STRATEGY: manual + # default production ref name (pattern) PROD_REF: '/^(master|main)$/' # default integration ref name (pattern) @@ -900,13 +904,13 @@ helm-publish: when: never - if: '$HELM_PUBLISH_ON == "protected" && $CI_COMMIT_REF_PROTECTED != "true"' when: never - - if: '$AUTODEPLOY_TO_PROD == "true"' + - if: '$HELM_PUBLISH_STRATEGY == "manual"' exists: - "**/Chart.yaml" - # else: manual + blocking - - exists: - - "**/Chart.yaml" when: manual + - if: '$HELM_PUBLISH_STRATEGY == "auto"' + exists: + - "**/Chart.yaml" # Deploy job prototype # Can be extended to define a concrete environment @@ -1208,10 +1212,6 @@ helm-production: # exclude if $HELM_PROD_ENABLED not set - if: '$HELM_PROD_ENABLED != "true"' when: never - # if $AUTODEPLOY_TO_PROD: auto - - if: '$AUTODEPLOY_TO_PROD == "true"' - # else if PUBLISH_ON_PROD enabled: auto (because the publish job was blocking) - - if: '$PUBLISH_ON_PROD == "true"' - # else: manual, blocking - - if: $CI_COMMIT_REF_NAME # useless test, just to prevent GitLab warning + - if: '$HELM_PROD_DEPLOY_STRATEGY == "manual"' when: manual + - if: '$HELM_PROD_DEPLOY_STRATEGY == "auto"'