{"id":36490046,"url":"https://github.com/ocraviotto/yaml-updater","last_synced_at":"2026-01-12T01:54:59.600Z","repository":{"id":38380220,"uuid":"456800561","full_name":"ocraviotto/yaml-updater","owner":"ocraviotto","description":"Update your yamls values directly or via PR in your preferred git provider","archived":false,"fork":false,"pushed_at":"2022-06-05T19:59:21.000Z","size":10158,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-22T17:09:28.938Z","etag":null,"topics":["gitops"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ocraviotto.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-08T05:49:17.000Z","updated_at":"2022-11-21T07:48:09.000Z","dependencies_parsed_at":"2022-08-27T16:00:31.702Z","dependency_job_id":null,"html_url":"https://github.com/ocraviotto/yaml-updater","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/ocraviotto/yaml-updater","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocraviotto%2Fyaml-updater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocraviotto%2Fyaml-updater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocraviotto%2Fyaml-updater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocraviotto%2Fyaml-updater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ocraviotto","download_url":"https://codeload.github.com/ocraviotto/yaml-updater/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocraviotto%2Fyaml-updater/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28331303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"ssl_error","status_checked_at":"2026-01-12T00:36:15.229Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gitops"],"created_at":"2026-01-12T01:54:58.909Z","updated_at":"2026-01-12T01:54:59.595Z","avatar_url":"https://github.com/ocraviotto.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yaml-updater\n\nThis is a small tool for updating YAML files, either by updating a key value (with the option to create the yaml file if it does not exist), or removing a key (or a whole file).\nThe goal is to enable automating commits (and optionally PR creation) in a GitOps flow.\n\nThe difference between this and the forked [image-update](https://github.com/gitops-tools/image-updater) repository can be summed up as:\n\n1. Augmenting the scope of actions to be a yaml key/file updater, rather than simply limiting the tool to updating an image only (hence the name change)\n2. Modified libraries to allow for the above changes, and to fully support BitBucket\n3. Removal of the http and pubsub commands (limited cloud support for the pubsub, security concerns with the webhook). If you need/want that, make sure to check upstream\n\n## Command-line tool\n\nThe original code used to support additional commands, but as mentioned above, they were removed. However, the update functionality is still located under the update command and additional commands may be added in the future.\n\nTo see all existing options:\n\n```shell\n$ ./yaml-updater update --help\n```\n\n### Update a yaml via flags only\n\n\u003e **NOTE:** For more complex (or multiple) targets, it is recommended to use a \"repositories\" configuration file ([see below](#use-yaml-configuration)).\n\n```shell\n$ export GIT_USERNAME=my-user GIT_AUTH_TOKEN=my_token\n$ ./yaml-updater update --file-path service-a/deployment.yaml --change-source-name my-docker-code-repo --source-repo my-org/my-change-target-repo --source-branch master --update-key spec.template.spec.containers.0.image --branch-generate-name gitops- --new-value quay.io/myorg/my-image:v1.1.0\n```\n\nThis would create a new branch `gitops-[random]` from current master HEAD in a GitHub repository `my-org/my-change-target-repo`, and update the file `service-a/deployment.yaml` by changing the `spec.template.spec.containers.0.image` key in the file to `quay.io/myorg/my-image:v1.1.0`, creating a PR against master that would include a message `Automatic update from my-docker-code-repo`.\nIf you want to do the same for some of the other supported git services, set GIT_DRIVER: `GIT_DRIVER=bitbucketcloud` or `GIT_DRIVER=gitlab`\n\nIf you need to access to private GitLab or GitHub installation, you can provide the `--api-endpoint` flag (or use the corresponding `GIT_API_ENDPOINT` env variable)\n\nTo disable PR creation and commit directly to the `--source-branch` value, simply pass `--disable-pr-creation` (and make sure the source branch can be committed directly to).\nFor additional details, see below [Important: Updating the sourceBranch directly](#important-updating-the-sourcebranch-directly).\n\n### Use yaml configuration\n\nThe repositories config allows one to simplify calling the cli, or to apply the same value change to multiple files, branches or repositories. For example, for CI/CD pipelines it's simpler to write most of the update command flags as configuration, and provide it as a list of repository details to target changes, which as mentioned, also supports targeting multiple repositories or files (if the repository details are the same).\nFor example, the above section cli command could be simplified, so that the configuration would look like\n\n```yaml\nrepositories:\n  my-repository:\n    name: my-docker-code-repo\n    sourceRepo: my-org/my-change-target-repo\n    sourceBranch: master\n    filePath: service-a/deployment.yaml\n    updateKey: spec.template.spec.containers.0.image\n    branchGenerateName: gitops-\n```\nand the command could be as simple as\n\n```shell\n$ export GIT_USERNAME=my-user GIT_AUTH_TOKEN=my_token\n$ ./yaml-updater update --new-value quay.io/myorg/my-image:v1.1.0\n```\n\nThe repositories yaml configuration itself can be a relative or absolute path and be set with the `--config-path` flag or the `GIT_CONFIG_PATH` env var, and defaults to '.yaml-updater.yaml' when not set. \n\n\u003e Do note that, when using the configuration yaml, neither `--username`, `--driver` or `--auth-token` have a corresponding configuration field, as these are globally set and not particular to any repository.\n\u003e Likewise, every root or update command flag can be set as an env var of the form `GIT_` + the flag name with the dash replaced by an underscore and in uppercase. In the case of these flags, they were passed as env vars as they'll most likely be reused, but if not, call the updater and set them as flags instead.\n\u003e No need to set the driver if using `github`, which is the default.\n\nIn the above example, the `--new-value` `quay.io/myorg/my-image:v1.1.0` would be applied just as in the CLI example above. The main difference with this approach is that a project could configure multiple targets (i.e. different repositories, branches, files or even yaml keys) updated with the same value in one go (as long as the git service and the credentials are common!). \n\nFor example, a config file could look like:\n\n```yaml\nrepositories:\n  prod:\n    disabled: true\n    name: my-docker-code-repo\n    sourceRepo: my-org/my-change-target-repo\n    sourceBranch: master\n    filePath: service-a/deployment.yaml\n    updateKey: spec.template.spec.containers.0.image\n    branchGenerateName: gitops-\n  dev:\n    name: my-docker-code-repo\n    sourceRepo: my-org/my-change-target-repo\n    sourceBranch: dev\n    filePath: service-a/deployment.yaml\n    updateKey: spec.template.spec.containers.0.image\n    disablePRCreation: true\n```\n\nAnd then call the updater regularly like:\n\n```shell\n$ export GIT_USERNAME=my-user GIT_AUTH_TOKEN=my_token\n$ ./yaml-updater update --new-value [my-new-image-value]\n```\n\nbut when targeting production, something like\n\n```shell\n$ export GIT_USERNAME=my-user GIT_AUTH_TOKEN=my_token\n$ ./yaml-updater update --new-value [my-new-image-value] --only prod\n```\n\nThis would ensure that development changes are automatically committed, not creating PRs to master (first command) while creating a PR for master and not modifying dev if executing the second.\n\n\u003e A third variation could be \n\u003e ```shell\n\u003e $ export GIT_USERNAME=my-user GIT_AUTH_TOKEN=my_token\n\u003e $ ./yaml-updater update --new-value [my-new-image-value] --override-repositories \"prod,dev\" --disabled=false\n\u003e ```\n\u003e which would cause both to be enabled (overrides the `disable` key in both so effectively enabling them) and so it'd commit directly to dev and create a PR for master from branch `gitops-[random]`. \n\n\nFor more options and uses, see the section below on [Yaml configuration overrides](#yaml-configuration-overrides).\n\n\n### Yaml configuration overrides\n\nIf the config file exists and has repositories, command line flags can operate as overrides provided that the action is explicitly enabled (applied to **ALL** targeted repositories, though only effective on enabled repositories, unless the override is the `--disabled=false` flag). yaml-updater provides 3 flags for that:\n\n1. `--override-all` (Boolean): As indicated by the name, if passes, any repository config passed via CLI will override every configured repository defined in config with the given value. \n2. `--override-repositories` (String): This is a comma separated list of matching repository config keys so that repository config passed via CLI will override every matched configured repository with the given value.\n3. `--only` (String): This is also a comma separated list of matching repository config keys so that repository config passed via CLI will override every matched configured repository with the given value AND every matching repository will be enabled plus any NON matching key will be removed and not used at all.\n\n\u003e :warning: Using `only` has a slightly different semantics than the other 2 flags in that it will disable (remove) any repository not given in the `--only` flag.\n\n\u003e See `yaml-updater update --help` for additional details. \n\n\n### Important: Updating the sourceBranch directly\n\nBy default, changes are not committed directly, by via a PR with a branch whose name is prefixed with the value of `branchGenerateName` (`gitops-` by default).\nTo commit directly, make sure to either set `disablePRCreation` to `true` in the spec, or pass the corresponding `--disable-pr-creation` flag to the command.\n*NOTE:* This is meant to work with `--override-repository [repo-config-key]`. If no such flag is passed, and `yaml-updater` detects more than one repository being updated, the command will fail, unless the `-override-all` (Boolean) flag is passed.\n\nIf no value is provided for `branchGenerateName`, then the `sourceBranch` will be updated directly, this means that if you use `master`, there will not be a PR created, the commit will be applied directly, and the token needs to authorize access to push a change directly to `master`.\n\n## Building\n\nA `Dockerfile` is provided for building a container, but otherwise:\n\n```shell\n$ go build ./cmd/yaml-updater\n```\n\n## Docker images\n\nImages are available at `oscarc/yaml-updater` and there should soon be additional tags matching this repository tags.\n\n## Testing\n\n```shell\n$ go test ./...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focraviotto%2Fyaml-updater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Focraviotto%2Fyaml-updater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focraviotto%2Fyaml-updater/lists"}