Skip to content
git-commit

GitHub Action

Run kustomize to update images and push result to another repository

v1.1.0 Latest version

Run kustomize to update images and push result to another repository

git-commit

Run kustomize to update images and push result to another repository

Useful to push images updates to a master repository containing central manifests

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Run kustomize to update images and push result to another repository

uses: rusowyler/[email protected]

Learn more about this action in rusowyler/github-action-kustomize-and-push

Choose a version

github-action-kustomize-and-push

Useful to push images updates to a master repository containing central manifests.

When to use it?

If you are using Kubernetes, usually, after building and pushing a Docker image to it's registry you will probably need to push that new tag to the repository that has all your manifest.

Flow:

  • Clones the central repository
  • Runs: kustomize edit set image
  • Pushes the resulted manifest to the central repository

There are different variables to setup the action:

Inputs

kustomize-version (argument) [optional]

Kustomize version to use. If not set the latest available will be use. Check https://github.com/kubernetes-sigs/kustomize/releases for available versions

kustomize-edit-images (argument)

The images (space separated) to edit using kustomize. For example: node:8.15.0 mysql=mariadb For more information run: kustomize edit set image -h

user-email (argument)

The email that will be used for the commit in the destination-repository-name.

user-name (argument) [optional]

The name that will be used for the commit in the destination-repository-name. If not specified, the repository-username will be used instead.

repository-username (argument)

The repository we will push the kustomize results to. For the repository https://github.com/rusowyler/github-action-kustomize-and-push is rusowyler.

repository-name (argument)

For the repository https://github.com/rusowyler/github-action-kustomize-and-push is github-action-kustomize-and-push

branch (argument) [optional]

The branch name for the destination repository. It defaults to main.

directory (argument) [optional]

The directory to wipe and replace in the target repository. Defaults to wiping the entire repository

commit-message (argument) [optional]

The commit message to be used. Defaults to "Updated KUSTOMIZE_IMAGES from ORIGIN_COMMIT". ORIGIN_COMMIT and KUSTOMIZE_IMAGES are replaced by the URL@commit and the submited images

API_TOKEN_GITHUB (environment)

E.g.: API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}

Generate your personal token following the steps:

  • Go to the Github Settings (on the right hand side on the profile picture)
  • On the left hand side pane click on "Developer Settings"
  • Click on "Personal Access Tokens" (also available at https://github.com/settings/tokens)
  • Generate a new token, choose "Repo". Copy the token.

Then make the token available to the Github Action following the steps:

  • Go to the Github page for the repository that you push from, click on "Settings"
  • On the left hand side pane click on "Secrets"
  • Click on "Add a new secret" and name it "API_TOKEN_GITHUB"

Example usage

- name: Kustomize and push
  uses: rusowyler/github-action-kustomize-and-push@main
  env:
    API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
  with:
    kustomize-edit-images: "node:8.15.0"
    repository-username: "rusowyler"
    repository-name: "central-k8s-repository"
    user-email: [email protected]
    directory: enviroment/qa

TODO:

  • Add real world examples
  • Add a working example