PushFlows
type: "io.kestra.plugin.git.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. You can also learn about Git integration in the Version Control with Git documentation.
Examples
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
totargetNamespace
is optional and should only be considered as a helper for facilitating the Git workflow for simple use cases — only thenamespace
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: kestra # optional, uses "kestra" by default
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: kestra
commitMessage: "add flow {{ flow.namespace ~ '.' ~ flow.id }}"
Properties
authorEmail
- Type: string
- Dynamic: ✔️
- Required: ❌
The commit author email.
If null, no author will be set on this commit.
authorName
- Type: string
- Dynamic: ✔️
- Required: ❌
- Default:
username
The commit author name.
If null, the username will be used instead.
branch
- Type: string
- Dynamic: ✔️
- Required: ❌
- Default:
kestra
The branch to which files should be committed and pushed.
If the branch doesn't exist yet, it will be created.
cloneSubmodules
- Type: boolean
- Dynamic: ❌
- Required: ❌
Whether to clone submodules.
commitMessage
- Type: string
- Dynamic: ✔️
- Required: ❌
- Default:
Add flows from sourceNamespace
Git commit message.
dryRun
- Type: boolean
- Dynamic: ❌
- Required: ❌
- Default:
false
If true
, the task will only output modifications without pushing any file to Git yet. If false
(default), all listed files will be pushed to Git immediately.
flows
- Type:
- string
- array
- Dynamic: ✔️
- Required: ❌
- Default:
**
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 "{{ flow.id }}" 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
gitDirectory
- Type: string
- Dynamic: ✔️
- Required: ❌
- Default:
_flows
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.
includeChildNamespaces
- Type: boolean
- Dynamic: ❌
- Required: ❌
- Default:
false
Whether you want to push flows from child namespaces as well.
By default, it’s
false
, so the task will push only flows from the explicitly declared namespace without pushing flows from child namespaces. If set totrue
, flows from child namespaces will be pushed to child directories in Git. See the example below for a practical explanation:
Source namespace in the flow code | Git directory path | Synced to target namespace |
---|---|---|
namespace: dev | _flows/flow1.yml | namespace: prod |
namespace: dev | _flows/flow2.yml | namespace: prod |
namespace: dev.marketing | _flows/marketing/flow3.yml | namespace: prod.marketing |
namespace: dev.marketing | _flows/marketing/flow4.yml | namespace: prod.marketing |
namespace: dev.marketing.crm | _flows/marketing/crm/flow5.yml | namespace: prod.marketing.crm |
namespace: dev.marketing.crm | _flows/marketing/crm/flow6.yml | namespace: prod.marketing.crm |
passphrase
- Type: string
- Dynamic: ✔️
- Required: ❌
The passphrase for the privateKey
.
password
- Type: string
- Dynamic: ✔️
- Required: ❌
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).
privateKey
- Type: string
- Dynamic: ✔️
- Required: ❌
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.
sourceNamespace
- Type: string
- Dynamic: ✔️
- Required: ❌
- Default:
{{ flow.namespace }}
The source namespace from which flows should be synced to the gitDirectory
.
targetNamespace
- Type: string
- Dynamic: ✔️
- Required: ❌
The target namespace, intended as the production namespace.
If set, the
sourceNamespace
will be overwritten to thetargetNamespace
in the flow source code to prepare your branch for merging into the production namespace.
url
- Type: string
- Dynamic: ✔️
- Required: ❌
The URI to clone from.
username
- Type: string
- Dynamic: ✔️
- Required: ❌
The username or organization.
Was this page helpful?