Skip to main content

GitOps Action

GitOps action allows you to make commits and push to a remote repository.

update-pod-namespace.yaml
apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: update-pod-namespace
spec:
parameters:
- name: namespace
label: The new namespace
configs:
- type: Kubernetes::Pod
actions:
- name: Modify namespace
gitops:
repo:
url: https://github.com/example/repo
connection: connection://github/example
base: master
branch: playbooks-branch-{{.params.namespace}}
commit:
email: john@doe.com
author: John Doe
message: |
Modifying namespace from {{.config.namespace}} to {{.params.namespace}}
pr:
title: 'chore: Update namespace to {{.params.namespace}}'
tags:
- low
patches:
- path: navidrome.yaml
yq: '.metadata.namespace = "{{.params.namespace}}"'
files:
- path: { { .config.namespace } }
content: $delete
- path: '{{.params.namespace}}/namespace.yaml'
content: |
apiVersion: v1
kind: Namespace
metadata:
name: {{.params.namespace}}
info

On Github, GitLab and Azure Devops, it's possible to create Pull Requests as well.

FieldDescriptionSchemeRequiredTemplatable
repoRepository detailsRepositoryDetailtruetrue
commitCommit detailsCommittruetrue
prPull Request details (Valid only for GitHub & Azure Devops)PullRequesttrue
patchesList of patches to apply[]Patchtrue
filesList of files to create[]Filetrue
note

At least a patch or files config is required.

Repository Detail

FieldDescriptionSchemeRequiredTemplatable
connectionConnection name to use the credentials for the git repostring
urlURL of the git repositorystring
baseBranch to clone. (Defaults to "main")stringtrue
branchThe new branch to create. (Defaults to base branch specified above)stringtrue
typeSpecify the service the repository is hosted on (eg: github, gitlab, etc)string
note

Either the connection or the url is required.

For private GitLab repositories, please sepcify the type as "gitlab"

Commit Detail

FieldDescriptionSchemeRequiredTemplatable
authorAuthor namestringtruetrue
emailAuthor emailstringtrue
messageCommit messagestringtrue

Pull Request

FieldDescriptionSchemeRequiredTemplatable
titleTitle of the Pull requeststringtruetrue
tagsTags to add to the PR[]stringtrue

Patch

Patches modify existing files on the git repo. You can either use yq to modify yaml files or jq to modify json files.

FieldDescriptionSchemeRequiredTemplatable
pathPath to patchstringtruetrue
yqyq querystringfalsetrue
jqjq querystringfalsetrue

File

Files create or delete existing files on the git repo.

FieldDescriptionSchemeRequiredTemplatable
pathPath to filestringtruetrue
contentContent of the file. Use the $delete keyword to delete an existing filestringtruetrue

Templating

The template receives a environment variable that contain details about the corresponding config, check or component and the parameter(if applicable).

FieldDescriptionSchema
configConfig passed to the playbookConfigItem
componentComponent passed to the playbookComponent
checkCanary Check passed to the playbookCheck
paramsUser provided parameters to the playbookmap[string]string