Sync Sync

yaml
type: "io.kestra.plugin.git.Sync"

Synchronizes the code for namespace files and flows based on the current state in Git.

Replaced by SyncFlows and SyncNamespaceFiles. Files located in gitDirectory will be synced with namespace files under namespaceFilesDirectory folder. Any file not present in the gitDirectory but present in namespaceFilesDirectory will be deleted from namespace files to ensure that Git remains a single source of truth for your workflow and application code. If you don't want some files from Git to be synced, you can add them to a .kestraignore file at the root of your gitDirectory folder — that file works the same way as .gitignore.

If there is a _flows folder under the gitDirectory folder, any file within it will be parsed and imported as a flow under the namespace declared in the task. It's important to keep in mind that all flows must be located within the same directory without any nested directories. If you want to deploy all flows to kestra from Git using the Git Sync pattern, you have to place all your flows in the _flows directory. Adding namespace folders will result in an error and that's expected. Flows are not equivalent to Namespace Files — while Namespace Files can be stored in arbitrarily nested folders stored in Internal Storage, Flows are just metadata. Flows are sent to Kestra's API and stored in the database backend. This is why they follow a different deployment pattern and cannot be stored in nested folders in Git.

Another important aspect is that the namespace defined in the flow code might get overwritten (!) if the namespace defined within Git doesn't match the namespace or a child namespace defined in the Git Sync task. All Git deployments, both the Git Sync and Kestra's CI/CD integrations, operate on a namespace level to ensure namespace-level governance of permissions, secrets, and to allow separation of resources. If you leverage multiple namespaces in a monorepo, you can create multiple flows, each using the Git Sync task to sync specific Git directories to the desired namespaces.

Examples

Synchronizes namespace files and flows based on the current state in a Git repository. This flow can run either on a schedule (using the Schedule trigger) or anytime you push a change to a given Git branch (using the Webhook trigger).

yaml
id: sync_from_git
namespace: company.team

tasks:
  - id: git
    type: io.kestra.plugin.git.Sync
    url: https://github.com/kestra-io/scripts
    branch: main
    username: git_username
    password: "{{ secret('GITHUB_ACCESS_TOKEN') }}"
    gitDirectory: your_git_dir # optional, otherwise all files
    namespaceFilesDirectory: your_namespace_files_location # optional, otherwise the namespace root directory
    dryRun: true  # if true, print the output of what files will be added/modified or deleted without overwriting the files yet

triggers:
  - id: every_minute
    type: io.kestra.plugin.core.trigger.Schedule
    cron: "*/1 * * * *"

Properties

url

  • Type: string
  • Dynamic: ✔️
  • Required: ✔️

The URI to clone from.

branch

  • Type: string
  • Dynamic: ✔️
  • Required:

The initial Git branch.

cloneSubmodules

  • Type: boolean
  • Dynamic:
  • Required:

Whether to clone submodules.

dryRun

  • Type: boolean
  • Dynamic:
  • Required:

If true, the task will only display modifications without syncing any files yet. If false (default), all namespace files and flows will be overwritten based on the state in Git.

gitDirectory

  • Type: string
  • Dynamic: ✔️
  • Required:

Git directory to sync code from. If not specified, all files from a Git repository will be synchronized.

namespaceFilesDirectory

  • Type: string
  • Dynamic: ✔️
  • Required:

Namespace files directory to which files from Git should be synced. It defaults to the root directory of the namespace.

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.

username

  • Type: string
  • Dynamic: ✔️
  • Required:

The username or organization.

Outputs

Definitions

Was this page helpful?