Push
type: "io.kestra.plugin.git.Push"
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.
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
docker:
image: 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: myPAT
branch: feature_branch
inputFiles:
to_commit/avg_order.txt: "{{ outputs.generate_data.vars.average_order }}"
addFilesPattern:
- to_commit
commitMessage: "{{ inputs.commit_message }}"
Properties
branch
- Type: string
- Dynamic: ✔️
- Required: ✔️
The branch to which files should be committed and pushed.
If the branch doesn't exist yet, it will be created.
commitMessage
- Type: string
- Dynamic: ✔️
- Required: ✔️
Commit message.
addFilesPattern
- Type: array
- SubType: string
- Dynamic: ✔️
- Required: ❌
- Default:
[.]
Patterns of files to add to the commit. Default is .
which means all files.
A directory name (e.g.
dir
to adddir/file1
anddir/file2
) can also be given to add all files in the directory, recursively. File globs (e.g.*.py
) are not yet supported.
author
- Type: Push-Author
- Dynamic: ❌
- Required: ❌
Commit author.
cloneSubmodules
- Type: boolean
- Dynamic: ❌
- Required: ❌
Whether to clone submodules.
directory
- Type: string
- Dynamic: ✔️
- Required: ❌
The optional directory associated with the clone operation.
If the directory isn't set, the current directory will be used.
flows
- Type: Push-FlowFiles
- Dynamic: ❌
- Required: ❌
- Default:
{enabled=true, childNamespaces=true, gitDirectory=_flows}
Whether to push flows from the current namespace to Git.
inputFiles
- Type:
- object
- string
- Dynamic: ✔️
- Required: ❌
The files to create on the local filesystem. It can be a map or a JSON object.
namespaceFiles
- Type: NamespaceFiles
- Dynamic: ❌
- Required: ❌
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
orexclude
properties to limit which namespace files will be injected.
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.
url
- Type: string
- Dynamic: ✔️
- Required: ❌
The URI to clone from.
username
- Type: string
- Dynamic: ✔️
- Required: ❌
The username or organization.
Outputs
commitId
- Type: string
- Required: ❌
ID of the commit pushed.
Definitions
io.kestra.plugin.git.Push-FlowFiles
Properties
childNamespaces
- Type: boolean
- Dynamic: ❌
- Required: ❌
- Default:
true
Whether flows from child namespaces should be included.
enabled
- Type: boolean
- Dynamic: ❌
- Required: ❌
- Default:
true
Whether to push flows as YAML files to Git.
gitDirectory
- Type: string
- Dynamic: ✔️
- Required: ❌
- Default:
_flows
To which directory flows should be pushed (relative to directory
).
io.kestra.core.models.tasks.NamespaceFiles
Properties
enabled
- Type: boolean
- Dynamic: ❌
- Required: ❌
- Default:
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
- Type: array
- SubType: string
- Dynamic: ❌
- Required: ❌
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.
include
- Type: array
- SubType: string
- Dynamic: ❌
- Required: ❌
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.
io.kestra.plugin.git.Push-Author
Properties
email
- Type: string
- Dynamic: ✔️
- Required: ❌
The commit author email, if null no author will be set on this commit
name
- Type: string
- Dynamic: ✔️
- Required: ❌
The commit author name, if null the username will be used instead
Was this page helpful?