Managing state in CI/CD
This feature is considered in a beta stage. It is still being tested and may change. For more information, see the API lifecycle stages documentation.
This guide explains how to refresh state for both Local Filesystem and Versioned State Storage strategies while deploying your Dagster project.
If you're using Dagster+, the dg scaffold github-actions command will generate a GitHub Actions workflow that automatically refreshes state for all StateBackedComponents in your project.
Understanding state storage
Before configuring state refresh in your CI/CD pipeline, it's important to understand where component state is stored:
Versioned State Storage
State is written to your Dagster instance:
- Dagster+: State is written to Dagster+ managed state storage
- OSS: State is written to a configured backend (S3, GCS, etc.) that you set up
Local Filesystem
State is written to a .local_defs_state directory within your Python project, then copied into your Docker image or PEX build as part of your deployment artifact.
Dagster+ vs OSS
In Dagster+, connecting to the instance and copying project files into your deployment artifact is handled automatically by the deployment process.
In OSS, you need to ensure these steps are followed accurately in your deployment configuration.
OSS deployments
For OSS deployments, you'll run state refresh commands in your CI/CD pipeline before building your deployment artifacts.
Refreshing state in CI/CD
Run state refresh commands in your CI/CD pipeline (GitHub Actions, GitLab CI, etc.) before building your deployment artifacts.
Basic steps
- Install uv:
python -m pip install uv - Navigate to your project:
cd path/to/your/project - Run refresh command:
uv run dg utils refresh-defs-state