Skip to main content

yaml-update

yaml-update updates the values of specified keys in any YAML file. This step most often used to update image tags or digests in a Helm values and is commonly followed by a helm-template step.

Configuration

NameTypeRequiredDescription
pathstringYPath to a YAML file. This path is relative to the temporary workspace that Kargo provisions for use by the promotion process.
updates[]objectYThe details of changes to be applied to the file. At least one must be specified.
updates[].keystringYThe key to update within the file. For nested values, use dots to delimit key parts. e.g. image.tag. The syntax is identical to that supported by the json-update step and is documented in more detail here.
updates[].valuestringYThe new value for the key. Typically specified using an expression.

Output

NameTypeDescription
commitMessagestringA description of the change(s) applied by this step. Typically, a subsequent git-commit step will reference this output and aggregate this commit message fragment with other like it to build a comprehensive commit message that describes all changes.

Examples

Common Usage

In this example, a Helm values file is updated to use a new container image tag. After cloning the repository and clearing the output directory, the yaml-update step modifies values.yaml to use the image tag from the Freight being promoted. Using dot notation (image.tag), it updates the nested value in the YAML file.

This pattern is commonly used when you need to update Helm values files or other YAML-based configuration files with new versions or settings during the promotion process.

info

For more information on imageFrom and expressions, see the Expressions documentation.

vars:
- name: gitRepo
value: https://github.com/example/repo.git
steps:
- uses: git-clone
config:
repoURL: ${{ vars.gitRepo }}
checkout:
- commit: ${{ commitFrom(vars.gitRepo).ID }}
path: ./src
- branch: stage/${{ ctx.stage }}
create: true
path: ./out
- uses: git-clear
config:
path: ./out
- uses: yaml-update
config:
path: ./src/charts/my-chart/values.yaml
updates:
- key: image.tag
value: ${{ imageFrom("my/image").Tag }}
# Render manifests to ./out, commit, push, etc...