# Guide: helm chart<no value>
// <!-- Required for asciidoctor -->
:toc:
// Set toclevels to be at least your hugo [markup.tableOfContents.endLevel] config key
:toclevels: 4

== Helm Chart

Helm is a popular package manager for deploying applications on Kubernetes.
But, those packages can be outdated quickly.
In this guide we explore how we can automatically update Helm charts based on third-party dependencies.

=== Requirement

To use this guide, we need the following elements:

. Updatecli
. A Helm chart to update
. A GitHub Personal Access Token

==== Updatecli

{{< updatecli_description >}}

==== IDE

{{< ide_jsonschema >}}

==== Helm chart to update

Within this example, we'll use a Helm chart from the Jenkins infrastructure project located on link:https://github.com/jenkins-infra/helm-charts[github.com/jenkins-infra/helm-charts].
We want to check that the Helm chart is always using the latest chart application which, in this case, is the jenkins-wiki-exporter.

==== GitHub Personal Access Token

As we're going to interact with GitHub repository and GitHub packages, we need a personal access token.
More information on the GitHub documentation link:https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token[creating-a-personal-access-token]


=== Pipeline

==== Manifest

Updatecli expects one or more pipeline manifests to know what to do.
We use the command `updatecli pipeline diff --config updatecli.yaml` to load the manifest.
The `diff` allows us to run updatecli in dry-mode, identifying what updatecli would change. Then we execute `updatecli pipeline apply --config updatecli.yaml` to apply our updatecli pipeline.

As you'll see in our updatecli manifest, we define:

1. One "source" of kind "githubrelease" which describes where to retrieve the latest version of our application, jenkins-wiki-exporter, published on GitHub Release.
2. Two "conditions" which need to be satisfied before updating our Helm chart.
The first one, "DockerImagePublished" of kind "dockerimage", ensures that a Docker image "jenkinsciinfra/jenkins-wiki-exporter" exists on DockerHub where the tag is the same as the source output, the latest jenkins-wiki-exporter version.
The second one, "DockerContainerUsed" of kind "yaml", ensures that our Helm chart uses the right container name, "jenkinsciinfra/jenkins-wiki-exporter".
3. A "target" of kind "helmchart", with a chart name "charts/jenkins-wiki-exporter" and a file "values.yaml" where the key "image.tag" is set to the latest jenkins-wiki-exporter version.
If it's not the case then bump the patch version of the chart, as requested by `versionincrement: "patch"`.
4. An "scms" entry of kind "github", that describes which GitHub repository stores the Helm chart "code".
5. An "actions" entry of kind "github/pullrequest", that describes pull request parameters such as the labels assigned to the pull request created by updatecli, and the auto-merge strategy.

.updatecli.yaml
[source,yaml]
----
{{<include "assets/code_example/docs/guides/helm-chart/updatecli.yaml">}}
----

Now we run our updatecli pipeline using the following commands:

[source,shell]
----
export UPDATECLI_GITHUB_TOKEN=xxx
export UPDATECLI_GITHUB_ACTOR=yyy
updatecli pipeline diff --config updatecli.yaml
----

WARNING: Using environment variables to store credentials is convenient for running updatecli from a CI environment.
Another option is to use link:https://github.com/mozilla/sops[sops] but in either case, you should not leave your credentials unprotected.


**Spoiler Alert**: Command output

[source,text]
----
{{<include "assets/code_example/docs/guides/helm-chart/updatecli.output">}}
----

=== Go Further

Updatecli is used in more scenarios and with many more to come.
Please reach out if you have questions.
Meanwhile, here are additional resources that you can use to go further.

==== Resource

To extend this pipeline, you can find more customization on the updatecli documentation website.

In this pipeline we used the following resources:

* link:/docs/plugins/resource/yaml/[YAML] - the `yaml` resource used by the second condition.
* link:/docs/plugins/resource/github_release/[GitHub Release] - the `githubrelease` source.
* link:/docs/plugins/resource/helm_chart/[Helm Chart] - the `helmchart` target.
* link:/docs/plugins/scm/github/[GitHub] - the `github` scm.
* link:/docs/plugins/actions/github/[GitHub Pull Request] - the `github/pullrequest` action.
* link:/docs/plugins/resource/docker_image/[Docker Image] - the `dockerimage` resource used by the first condition.

==== Additional Workflows

Updatecli shines and saves us time in many other situations such as:

* link:/docs/guides/docker-compose/[Docker Compose] - keeping a `docker-compose.yaml` on the latest image tag or digest.
* link:/docs/guides/dockerfile/[Dockerfile] - how the Jenkins project keeps its Dockerfiles on the latest JDK.
* link:/docs/guides/npm/[npm] - tracking an npm dependency and refreshing the lock file.

==== Contributing

As a community-oriented project, all contributions are greatly appreciated!

Here is a non-exhaustive list of possible contributions:

* ⭐️ this link:https://github.com/updatecli/updatecli[updatecli/updatecli] repository.
* Propose a new feature request.
* Highlight an existing feature request with :thumbsup:.
* Contribute to any repository in the link:https://github.com/updatecli/[updatecli] organization
* Share the love

More information is available at link:https://github.com/updatecli/updatecli/blob/main/CONTRIBUTING.adoc[CONTRIBUTING]
