PushFlows
Commit and push your saved flows to a Git repository.
Using this task, you can push one or more flows from a given namespace (and optionally also child namespaces) to Git. Check the examples below to see how you can push all flows or only specific ones. To learn more, check the Version Control with Git guide.
type: "io.kestra.plugin.git.PushFlows"
Release all flows and scripts from selected namespaces to a Git repository every Thursday at 11: 00 AM. Adjust the values
list to include the namespaces for which you want to push your code to Git. This System Flow will create two commits per namespace: one for the flows and one for the scripts.
id: git_push
namespace: system
tasks:
- id: push
type: io.kestra.plugin.core.flow.ForEach
values: ["company", "company.team", "company.analytics"]
tasks:
- id: flows
type: io.kestra.plugin.git.PushFlows
sourceNamespace: "{{ taskrun.value }}"
gitDirectory: "{{'flows/' ~ taskrun.value}}"
includeChildNamespaces: false
- id: scripts
type: io.kestra.plugin.git.PushNamespaceFiles
namespace: "{{ taskrun.value }}"
gitDirectory: "{{'scripts/' ~ taskrun.value}}"
pluginDefaults:
- type: io.kestra.plugin.git
values:
username: anna-geller
url: https://github.com/anna-geller/product
password: "{{ secret('GITHUB_ACCESS_TOKEN') }}"
branch: main
dryRun: false
triggers:
- id: schedule_push_to_git
type: io.kestra.plugin.core.trigger.Schedule
cron: "0 11 * * 4"
Automatically push all saved flows from the dev namespace and all child namespaces to a Git repository every day at 5 p.m. Before pushing to Git, the task will adjust the flow's source code to match the targetNamespace to prepare the Git branch for merging to the production namespace. Note that the automatic conversion of sourceNamespace
to targetNamespace
is optional and should only be considered as a helper for facilitating the Git workflow for simple use cases — only the namespace
property within the flow will be adjusted and if you specify namespace names within e.g. Flow triggers, those may need to be manually adjusted. We recommend using separate Kestra instances for development and production with the same namespace names across instances.
id: push_to_git
namespace: system
tasks:
- id: commit_and_push
type: io.kestra.plugin.git.PushFlows
sourceNamespace: dev # the namespace from which flows are pushed
targetNamespace: prod # the target production namespace; if different than sourceNamespace, the sourceNamespace in the source code will be overwritten by the targetNamespace
flows: "*" # optional list of glob patterns; by default, all flows are pushed
includeChildNamespaces: true # optional boolean, false by default
gitDirectory: _flows
url: https://github.com/kestra-io/scripts # required string
username: git_username # required string needed for Auth with Git
password: "{{ secret('GITHUB_ACCESS_TOKEN') }}"
branch: main
commitMessage: "add flows {{ now() }}" # optional string
dryRun: true # if true, you'll see what files will be added, modified or deleted based on the state in Git without overwriting the files yet
triggers:
- id: schedule_push
type: io.kestra.plugin.core.trigger.Schedule
cron: "0 17 * * *" # release/push to Git every day at 5pm
Manually push a single flow to Git if the input push is set to true.
id: myflow
namespace: prod
inputs:
- id: push
type: BOOLEAN
defaults: false
tasks:
- id: if
type: io.kestra.plugin.core.flow.If
condition: "{{ inputs.push == true}}"
then:
- id: commit_and_push
type: io.kestra.plugin.git.PushFlows
sourceNamespace: prod # optional; if you prefer templating, you can use "{{ flow.namespace }}"
targetNamespace: prod # optional; by default, set to the same namespace as defined in sourceNamespace
flows: myflow # if you prefer templating, you can use "{{ flow.id }}"
url: https://github.com/kestra-io/scripts
username: git_username
password: "{{ secret('GITHUB_ACCESS_TOKEN') }}"
branch: main
commitMessage: "add flow {{ flow.namespace ~ '.' ~ flow.id }}"
The branch to which files should be committed and pushed.
If the branch doesn't exist yet, it will be created.
Git commit message.
List of glob patterns or a single one that declare which flows should be included in the Git commit.
By default, all flows from the specified sourceNamespace will be pushed (and optionally adjusted to match the targetNamespace before pushing to Git).
If you want to push only the current flow, you can use the "" expression or specify the flow ID explicitly, e.g. myflow.
Given that this is a list of glob patterns, you can include as many flows as you wish, provided that the user is authorized to access that namespace.
Note that each glob pattern try to match the file name OR the relative path starting from gitDirectory
Directory to which flows should be pushed.
If not set, flows will be pushed to a Git directory named _flows and will optionally also include subdirectories named after the child namespaces.
If you prefer, you can specify an arbitrary path, e.g., kestra/flows, allowing you to push flows to that specific Git directory.
If the includeChildNamespaces
property is set to true, this task will also push all flows from child namespaces into their corresponding nested directories, e.g., flows from the child namespace called prod.marketing will be added to the marketing folder within the _flows folder.
Note that the targetNamespace (here prod) is specified in the flow code; therefore, kestra will not create the prod directory within _flows. You can use the PushFlows task to push flows from the sourceNamespace, and use SyncFlows to then sync PR-approved flows to the targetNamespace, including all child namespaces.
The passphrase for the privateKey
.
The password or Personal Access Token (PAT). When you authenticate the task with a PAT, any flows or files pushed to Git from Kestra will be pushed from the user associated with that PAT. This way, you don't need to configure the commit author (the authorName
and authorEmail
properties).
PEM-format private key content that is paired with a public key registered on Git.
To generate an ECDSA PEM format key from OpenSSH, use the following command: ssh-keygen -t ecdsa -b 256 -m PEM
. You can then set this property with your private key content and put your public key on Git.
The source namespace from which flows should be synced to the gitDirectory
.
The target namespace, intended as the production namespace.
If set, the sourceNamespace
will be overwritten to the targetNamespace
in the flow source code to prepare your branch for merging into the production namespace.
The URI to clone from.
The username or organization.