PushFlows icon
PushNamespaceFiles icon
Schedule icon

Push code to Git at regular intervals

Automatically push Kestra flows and namespace files to a Git repository on a schedule for GitOps version control, audit history, and backups.

Categories
CoreInfrastructureSystem

Keep your Git repository in sync with what is actually running in Kestra. This flow automatically pushes flow definitions and namespace files to GitHub every 15 minutes, giving you continuous version control, audit history, and a reliable backup of your orchestration code without anyone remembering to commit. It closes the gap between the code editing in the Kestra UI and a Git-backed GitOps workflow, so every change is tracked, reviewable, and recoverable.

How it works

A io.kestra.plugin.core.trigger.Schedule trigger fires on the cron */15 * * * *, running the flow every 15 minutes. On each run:

  1. The push_flows task (io.kestra.plugin.git.PushFlows) exports all flows (flows: "*") from the dev source namespace, including child namespaces, and commits them to the _flows directory on the kestra branch. It can retarget them to a prod namespace via targetNamespace, with a commit message stamped using {{ now() }}.
  2. The push_namespace_files task (io.kestra.plugin.git.PushNamespaceFiles) exports all namespace files (files: "*") from the dev namespace into the _files directory and commits them on the dev branch.

Both tasks authenticate to https://github.com/kestra-io/scripts with a username and a token stored in {{ secret('GITHUB_ACCESS_TOKEN') }}. They run with dryRun: true so you can preview the exact diff before flipping to real commits.

What you get

  • Automatic, scheduled commits of every flow and namespace file
  • A continuously updated backup of your orchestration code in Git
  • Full audit history of who changed what and when, via Git
  • A safe dryRun preview before any real push
  • Separation of flows and files into dedicated directories and branches

Who it's for

  • Platform and DevOps engineers standardizing GitOps for Kestra
  • Data engineering teams that need versioned, recoverable workflow code
  • Organizations with audit and compliance requirements for change tracking

Why orchestrate this with Kestra

Git itself has no scheduler and no awareness of your Kestra instance: it cannot decide when to snapshot your flows or pull them out of the platform. Kestra fills that gap. Event and schedule triggers drive the sync automatically, retries handle transient network or auth failures, and execution history gives you lineage for every push. Everything is declared in plain YAML, so the backup pipeline is itself versioned and reproducible. You can swap the schedule for an event trigger, fan out to multiple repositories, or gate pushes behind approvals, none of which a raw git cron job can express cleanly.

Prerequisites

  • A Kestra instance with flows and namespace files in the dev namespace
  • A GitHub repository you can push to (here kestra-io/scripts)
  • The plugin-git plugin available (bundled with Kestra)

Secrets

  • GITHUB_ACCESS_TOKEN: a GitHub personal access token (or fine-grained token) with write access to the target repository.

Quick start

  1. Add your GITHUB_ACCESS_TOKEN secret to Kestra.
  2. Update url, username, branch, and the source/target namespaces to match your setup.
  3. Run once with dryRun: true and inspect the planned commit in the logs.
  4. Set dryRun: false on both tasks to start pushing for real.
  5. Adjust the cron if 15 minutes is too frequent or not frequent enough.

How to extend

  • Replace the Schedule trigger with a flow trigger to push only after deployments.
  • Point push_flows at additional namespaces or pin specific flows instead of "*".
  • Push to multiple repositories or branches by duplicating the tasks.
  • Pair with io.kestra.plugin.git.SyncFlows to build a full two-way GitOps loop.

Links

Orchestrate with Kestra
Orchestrate Git with Kestra
Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.