Pablo MARTIN CALVO
03/23/2026, 1:33 PMprefect deploy (or similar) from CI/CD?
Specifically: does Prefect support something like continuous sync of deployment definitions from a repo (polling or webhooks), or is the supported pattern always “register deployments via CLI/API/CI” while pull steps only handle flow code at run time?Marvin
03/23/2026, 1:33 PMMarvin
03/23/2026, 1:37 PMfrom prefect import flow
from prefect.runner.storage import GitRepository
repo = GitRepository(
url="<https://github.com/org/repo.git>",
branch="main",
pull_interval=60 # refresh code every 60s
)
@flow
def my_flow():
...
my_flow.from_source(
source=repo,
entrypoint="flows/my_flow.py:my_flow",
).deploy(
name="my-deployment",
work_pool_name="k8s-pool",
)
- Notes for Kubernetes:
- Ensure your worker image has git installed and can auth to your repo (HTTPS token, SSH key, or a Prefect GitCredentials block).
- pull_interval defaults to 60s; set None for a one-time pull at run start.
What this does and doesn’t cover
- Covered:
- You push code to main; the worker periodically pulls and new runs use the latest code with no re-deploy.
- Not covered:
- New flows (new entrypoints) or new deployments are not auto-created.
- Changes to deployment metadata (schedule, parameters, infrastructure, etc.) still require running flow.deploy() or prefect deploy in CI/CD.
No built-in webhook/polling for auto-registration
- There is no Prefect service that scans your repo and auto-registers deployments.
- Prefect Cloud’s GitHub App helps with short-lived tokens for secure pulls, but it does not auto-create deployments.
If you want “continuous sync” of deployments anyway
- Common pattern: run prefect deploy (or call flow.deploy()) from CI on push to main. This keeps deployment definitions explicit and auditable.
- You can build a custom controller (a small Prefect flow) that scans a repo and upserts deployments via the API, but this is not built-in.
Relevant links
- Git-based storage class with pull_interval in source: prefect.runner.storage.GitRepository
- Worker pull loop (periodic refresh before runs): _scheduled_run_poller
- Deployments overview/docs: Deploy flows (Prefect docs)
- CLI for deployments (use prefect deploy; do not use the removed “deployment build”): prefect deploy (docs)
Bottom line
- For Prefect 3, the official, supported pattern is:
- Register deployments via CLI/API/CI
- Let workers pull code at run time (and optionally refresh via pull_interval)
- There is no built-in, Airflow-style continuous sync that auto-registers new/updated flows from Git.