# Guide: helm chart<no value>

:toc: right

== 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 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 diff --config manifest.yaml` to use the manifests.
The `diff` allows us to run updatecli in dry-mode, identifying what updatecli would change. Then we to execute `updatecli apply --config manifest.yaml` to apply our updatecli pipeline

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

1. One "source" resource of a kind "githubRelease" which describes, where to retrieve the latest version of our application, jenkins-wiki-exporter, published on GitHub Release.
2. Two "condition" "resources which need to be satisfied before updating our Helm chart.
In the first condition, we want to ensure that our Helm chart uses the right container name, "jenkinsciinfra/jenkins-wiki-exporter". The second condition of a 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.
3. A "target" resource of the kind "helmChart", has a chart name "charts/jenkins-wiki-exporter" with 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 path version of the chart.
4. A "scms" resource of kind "github", that describes which GitHub repository stores the Helm chart "code".
5. A "pullrequest" resource of kind "github", that describes pull-request parameters such as the label assigned to the pull request created by updatecli, and the auto-merge flag.

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

Now we run our updatecli pipeline using the following commands:

```
export GITHUB_TOKEN=xxx
export GITHUB_ACTOR=yyy
updatecli 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,yaml]
----
# data.yaml
{{<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:https://www.updatecli.io/docs/plugins/yaml/[YAML]
* link:https://www.updatecli.io/docs/plugins/github_release/[GitHub Release]
* link:https://www.updatecli.io/docs/plugins/helm_chart/[Helm Chart]
* link:https://www.updatecli.io/docs/plugins/github/[GitHub Repository]
* link:https://www.updatecli.io/docs/plugins/github_pullrequest/[GitHub Pullrequest]
* link:https://www.updatecli.io/docs/plugins/docker_image/[Docker Image]

==== Additional Workflows

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

* Automatically updating any YAML
* Automatically updating Dockerfile
* Automatically updating raw 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]
