CLI toolkit for detecting and applying Prefect deployment changes in CI/CD pipelines
Project description
Prefect Deployments Toolkit
A lightweight CLI toolkit for managing Prefect deployment lifecycles in CI/CD pipelines. It detects deployments that were added, modified, or removed between two git references, and applies (creates, updates, or deletes) those deployments against Prefect Cloud or a self-hosted Prefect server — via either the Prefect CLI or direct REST API calls.
Built for teams running many Prefect flows out of a monorepo, where each deployment is defined in its own YAML file alongside a shared prefect_base.yaml, and CI needs to figure out which deployments actually changed before re-registering them.
Features
- Change detection — diff deployments between two git refs (a merge request source vs. target branch, or
HEAD~1vs.HEADafter a merge) and get back exactly which deployments were added, modified, or removed. - Unified push / pull-request logic — one code path handles both
pull_request(compare local files against a fetched base branch) andpush/pull_request_target(compareHEAD~1againstHEAD) event styles. - Dual deploy backends — apply deployments using the
prefectCLI as a subprocess, or bypass it entirely with direct Prefect Cloud REST API calls for faster, more controllable deploys. - Dev/prod environment overrides — automatic name prefixing, work pool substitution, and schedule pausing for dev environments.
- Concurrent deployment application — apply multiple deployments in parallel with clean, non-interleaved log output per deployment.
- Duplicate deployment name detection — warns (or optionally cleans up) when the same deployment name resolves to more than one flow.
Installation
pip install prefect-deployments-toolkit
Requires Python >= 3.10.
Usage
1. Detect modified deployments
python -m prefect_deployments_toolkit.get_modified_deployments \
--modified-by push \
--base-ref main \
--deployments-dir deployments
Prints a comma-separated list of changed deployment names to stdout, and (if running inside GitHub Actions) writes DEPLOYMENT_NAMES, NEW_OR_MODIFIED_DEPLOYMENT_NAMES, and REMOVED_DEPLOYMENT_NAMES to GITHUB_ENV.
--modified-by accepts:
pull_request— compares your local working tree against the fetched base branch (use during an open MR/PR).pushorpull_request_target— comparesHEAD~1againstHEAD(use after a merge to a protected branch).
2. Apply deployments
python -m prefect_deployments_toolkit \
--deployment-names "flow_a,flow_b" \
--enable-schedule false \
--tag dev \
--reference feature-branch-1 \
--repo-name my-flows-repo \
--custom-image "" \
--deployments-dir deployments \
--dev-work-pool my-dev-work-pool \
--backend rest \
--enforce-unique-deployment-names false
Expected Repository Layout
deployments/
├── prefect_base.yaml # shared config merged into every deployment
├── flow_a.yaml
├── flow_b.yaml
└── ...
Each deployment YAML file must declare a deployments: list with at least a name and entrypoint key, following the standard Prefect deployment YAML schema.
Backends
| Backend | How it works | When to use |
|---|---|---|
cli |
Shells out to prefect deploy |
Simplest, matches local prefect deploy behavior exactly |
rest |
Talks directly to the Prefect Cloud REST API | Faster for many concurrent deployments, avoids CLI subprocess overhead |
Environment Variables
| Variable | Required | Purpose |
|---|---|---|
PREFECT_API_URL |
Yes | Full Prefect Cloud/server API base URL |
PREFECT_API_KEY |
Yes | API key for authentication |
License
Licensed under PolyForm Noncommercial 1.0.0. You may view, use, and modify this software for noncommercial purposes. Commercial use — including building products, services, or automation on top of it — requires a separate license. Contact [your contact info] for commercial licensing inquiries.
Contributing
Issues and pull requests are welcome for noncommercial use cases. Please open an issue before submitting a large PR to discuss scope.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prefect_deployments_toolkit-0.0.1.tar.gz.
File metadata
- Download URL: prefect_deployments_toolkit-0.0.1.tar.gz
- Upload date:
- Size: 21.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ad95745177b06d6bfa86420704bee81d01bfcae3d5cc32b482181864cbffb00
|
|
| MD5 |
a10dd14161f7f478461031e79bfb4c8e
|
|
| BLAKE2b-256 |
ce80c262bf5a023f66129726a592b8937a8c6bd20b8c68e20e40b5e14b591c63
|
Provenance
The following attestation bundles were made for prefect_deployments_toolkit-0.0.1.tar.gz:
Publisher:
cd.yml on dyvenia/prefect-deployments-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prefect_deployments_toolkit-0.0.1.tar.gz -
Subject digest:
6ad95745177b06d6bfa86420704bee81d01bfcae3d5cc32b482181864cbffb00 - Sigstore transparency entry: 2062352366
- Sigstore integration time:
-
Permalink:
dyvenia/prefect-deployments-toolkit@077160f0688d955aee217289adb196b6a9685ab3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dyvenia
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@077160f0688d955aee217289adb196b6a9685ab3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file prefect_deployments_toolkit-0.0.1-py3-none-any.whl.
File metadata
- Download URL: prefect_deployments_toolkit-0.0.1-py3-none-any.whl
- Upload date:
- Size: 25.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
492d76bfae47760e1c43f1ff10c032050b44dd8ab5e2a52cc25f322bda478fc9
|
|
| MD5 |
19ec7dadecb3eff75e6f1b838b9d2425
|
|
| BLAKE2b-256 |
91ea3db1ea7a3d560df371252e9269d921f798ac277246e7d4417d2b4235879a
|
Provenance
The following attestation bundles were made for prefect_deployments_toolkit-0.0.1-py3-none-any.whl:
Publisher:
cd.yml on dyvenia/prefect-deployments-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prefect_deployments_toolkit-0.0.1-py3-none-any.whl -
Subject digest:
492d76bfae47760e1c43f1ff10c032050b44dd8ab5e2a52cc25f322bda478fc9 - Sigstore transparency entry: 2062352473
- Sigstore integration time:
-
Permalink:
dyvenia/prefect-deployments-toolkit@077160f0688d955aee217289adb196b6a9685ab3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dyvenia
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@077160f0688d955aee217289adb196b6a9685ab3 -
Trigger Event:
workflow_dispatch
-
Statement type: