Commit and push files to a Git repository.
Replaced by PushFlows and PushNamespaceFiles for flow and namespace files push scenario. You can add inputFiles
to be committed and pushed. Furthermore, you can use this task in combination with the Clone
task so that you can first clone the repository, then add or modify files and push to Git afterwards. " +
"Check the examples below as well as the Version Control with Git documentation for more information. 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.push"
Examples
Push flows and namespace files to a Git repository every 15 minutes.
id: push_to_git
namespace: company.team
tasks:
- id: commit_and_push
type: io.kestra.plugin.git.Push
namespaceFiles:
enabled: true
flows:
enabled: true
url: https://github.com/kestra-io/scripts
branch: kestra
username: git_username
password: "{{ secret('GITHUB_ACCESS_TOKEN') }}"
commitMessage: "add flows and scripts {{ now() }}"
triggers:
- id: schedule_push
type: io.kestra.plugin.core.trigger.Schedule
cron: "*/15 * * * *"
Clone the main branch, generate a file in a script, and then push that new file to Git. Since we're in a working directory with a .git
directory, you don't need to specify the URL in the Push task. However, the Git credentials always need to be explicitly provided on both Clone and Push tasks (unless using task defaults).
id: push_new_file_to_git
namespace: company.team
inputs:
- id: commit_message
type: STRING
defaults: add a new file to Git
tasks:
- id: wdir
type: io.kestra.plugin.core.flow.WorkingDirectory
tasks:
- id: clone
type: io.kestra.plugin.git.Clone
branch: main
url: https://github.com/kestra-io/scripts
- id: generate_data
type: io.kestra.plugin.scripts.python.Commands
taskRunner:
type: io.kestra.plugin.scripts.runner.docker.Docker
containerImage: ghcr.io/kestra-io/pydata:latest
commands:
- python generate_data/generate_orders.py
- id: push
type: io.kestra.plugin.git.Push
username: git_username
password: "{{ secret('GITHUB_ACCESS_TOKEN') }}"
branch: feature_branch
inputFiles:
to_commit/avg_order.txt: "{{ outputs.generate_data.vars.average_order }}"
addFilesPattern:
- to_commit
commitMessage: "{{ inputs.commit_message }}"
Properties
branch *Requiredstring
The branch to which files should be committed and pushed
If the branch doesn't exist yet, it will be created.
commitMessage *Requiredstring
Commit message
addFilesPattern array
["."]
Patterns of files to add to the commit -- default is .
which means all files.
A directory name (e.g., dir
to add dir/file1
and dir/file2
) can also be given to add all files in the directory, recursively. File globs (e.g., *.py
) are not yet supported.
cloneSubmodules booleanstring
Whether to clone submodules
directory string
The optional directory associated with the push operation
If the directory isn't set, the current directory will be used.
flows Non-dynamicPush-FlowFiles
{
"enabled": "true",
"childNamespaces": "true",
"gitDirectory": "_flows"
}
Whether to push flows from the current namespace to Git
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
inputFiles objectstring
The files to create on the working. It can be a map or a JSON object.
Each file can be defined:
- Inline with its content
- As a URI, supported schemes are
kestra
for internal storage files,file
for host local files, andnsfile
for namespace files.
namespaceFiles Non-dynamicNamespaceFiles
Inject namespace files.
Inject namespace files to this task. When enabled, it will, by default, load all namespace files into the working directory. However, you can use the include
or exclude
properties to limit which namespace files will be injected.
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
Outputs
commitId string
ID of the commit pushed.
Definitions
io.kestra.plugin.git.Push-FlowFiles
childNamespaces booleanstring
true
Whether flows from child namespaces should be included
enabled booleanstring
true
Whether to push flows as YAML files to Git
gitDirectory string
_flows
To which directory flows should be pushed (relative to directory
)
io.kestra.core.models.tasks.NamespaceFiles
enabled booleanstring
true
Whether to enable namespace files to be loaded into the working directory. If explicitly set to true
in a task, it will load all Namespace Files into the task's working directory. Note that this property is by default set to true
so that you can specify only the include
and exclude
properties to filter the files to load without having to explicitly set enabled
to true
.
exclude array
A list of filters to exclude matching glob patterns. This allows you to exclude a subset of the Namespace Files from being downloaded at runtime. You can combine this property together with include
to only inject a subset of files that you need into the task's working directory.
folderPerNamespace booleanstring
false
Whether to mount file into the root of the working directory, or create a folder per namespace
ifExists string
OVERWRITE
OVERWRITE
FAIL
WARN
IGNORE
Comportment of the task if a file already exist in the working directory.
include array
A list of filters to include only matching glob patterns. This allows you to only load a subset of the Namespace Files into the working directory.
namespaces array
["{{flow.namespace}}"]
A list of namespaces in which searching files. The files are loaded in the namespace order, and only the latest version of a file is kept. Meaning if a file is present in the first and second namespace, only the file present on the second namespace will be loaded.
io.kestra.plugin.git.Push-Author
email string
The commit author email, if null no author will be set on this commit
name string
The commit author name, if null the username will be used instead