PushNamespaceFiles
Commit and push Namespace Files created from Kestra’s UI to Git.
Using this task, you can push one or more Namespace Files from a given kestra namespace to Git. Note that in contrast to PushFlows
, this task requires pushing code for each namespace separately. You can use the ForEach
task as shown below to loop over multiple namespaces. Check the Version Control with Git guide for more examples.
Git does not guarantee the order of push operations to a remote repository, which can lead to potential conflicts when multiple users or flows attempt to push changes simultaneously.
To minimize the risk of data loss and merge conflicts, it is strongly recommended to use sequential workflows or push changes to separate branches.
type: "io.kestra.plugin.git.PushNamespaceFiles"
Examples
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"
Push all saved Namespace Files from the dev namespace to a Git repository every 15 minutes.
id: push_to_git
namespace: system
tasks:
- id: commit_and_push
type: io.kestra.plugin.git.PushNamespaceFiles
namespace: dev
files: "**" # optional list of glob patterns; by default, all files are pushed
gitDirectory: _files # optional path in Git where Namespace Files should be pushed
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: dev # optional, uses "kestra" by default
commitMessage: "add namespace files" # 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_to_git
type: io.kestra.plugin.core.trigger.Schedule
cron: "*/15 * * * *"
Properties
branch string
main
The branch to which Namespace Files should be committed and pushed
If the branch doesn’t exist yet, it will be created. If not set, the task will push the files to the kestra
branch.
cloneSubmodules booleanstring
Whether to clone submodules
commitMessage string
Add files from `namespace` namespace
Git commit message
delete booleanstring
true
Whether to delete flows/files from Git that are no longer present in Kestra
If true
(default), files present in Git but not in Kestra will be deleted from the Git repository.
dryRun booleanstring
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.
errorOnMissing booleanstring
false
Fail the task if no files are matched
If true, the task will fail explicitly when no files are matched by the provided 'files' property.
files object
**
Which Namespace Files should be included in the commit
By default, Kestra will push all Namespace Files from the specified namespace.
If you want to push only a specific file or directory (e.g., myfile.py), you can set it explicitly using files: myfile.py.
Given that this is a glob pattern string (or a list of glob patterns), you can include as many files 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
gitConfig object
Git configuration to apply to the repository
Map of Git config keys and values, applied after clone few examples: - 'core.fileMode': false -> ignore file permission changes - 'core.autocrlf': false -> prevent line ending conversion
gitDirectory string
_files
Directory to which Namespace Files should be pushed.
If not set, files will be pushed to a Git directory named _files
. See the table below for an example mapping of Namespace Files to Git paths:
Namespace File Path | Git directory path |
---|---|
scripts/app.py | _files/scripts/app.py |
scripts/etl.py | _files/scripts/etl.py |
queries/orders.sql | _files/queries/orders.sql |
queries/customers.sql | _files/queries/customers.sql |
requirements.txt | _files/requirements.txt |
namespace string
{{ flow.namespace }}
The namespace from which files should be pushed to the gitDirectory
passphrase string
The passphrase for the privateKey
password string
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 string
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.
trustedCaPemPath string
Optional path to a PEM-encoded CA certificate to trust (in addition to the JVM default truststore)
Equivalent to git config http.sslCAInfo <path>
. Use this for self-signed/internal CAs.
url string
The URI to clone from
username string
The username or organization