Branch Deployments in Dagster Cloud#

Branch Deployments automatically create staging environments of your Dagster code, right in Dagster Cloud. For every push to a branch in your git repository, Dagster Cloud will create a unique deployment, allowing you to preview the changes in the branch in real-time.


Understanding Branch Deployments#

Overview#

Think of a branch deployment as a branch of your data platform, one where you can preview changes without impacting production or overwriting a testing environment.

Let's take a closer look:

  1. In your git repository, a new branch is created off of main. In the example above, this branch is named feature-1.

  2. Dagster Cloud is notified of the push and creates a branch deployment named feature-1. The branch deployment functions just like your production deployment of Dagster Cloud, but contains the Dagster code changes from the feature-1 branch.

    In this example, the feature-1 branch deployment 'talks' to a cloned schema in a database. This is completely separate from the prod schema associated with the production deployment.

  3. For every push to the feature-1 branch, the feature-1 branch deployment in Dagster Cloud is re-built and re-deployed.

Benefits#

Now that you know how Branch Deployments work, why should you use them?

  • Improved collaboration. Branch Deployments make it easy for everyone on your team to stay in the loop on the latest Dagster changes.
  • Reduced development cycle. Quickly test and iterate on your changes without impacting production or overwriting a testing environment.

Requirements#

To use Branch Deployments, you'll need a Dagster Cloud account.

Supported platforms#

Branch Deployments can be used with any git or CI provider. However, setup is easiest with the Dagster GitHub app as parts of the process are automated. Refer to the Setting up Branch Deployments section for more info.

Limitations#

The following aren't currently supported for Branch Deployments:

Output handling#

Output created from a branch deployment - such a database, table, etc. - won't be automatically removed from storage once a branch is merged or closed. Refer to the Best practices section for info on how to handle this.


Managing Branch Deployments#

Setting up Branch Deployments#

There are currently two ways to set up Branch Deployoments for Dagster Cloud. In the table below:

  • Platform - The name of the git/CI platform, which is also a link to a setup guide
  • How it works - Summary of how Branch Deployments work with the platform
  • May be a good fit if... - A high-level summary of when the platform may be a good fit
PlatformHow it worksMay be a good fit if...
GitHubGitHub Actions
  • You use GitHub for version control
  • You want Dagster to fully automate Branch Deployments
Other git/CI platform dagster-cloud CLI
  • You don't use GitHub for version control
  • You use an alternate CI platform
  • You want full control over Branch Deployment configuration

Accessing a branch deployment#

Once configured, branch deployments can be accessed:

From a GitHub pull request#

Every pull request in the repository contains a View in Cloud link:

View in Cloud preview link highlighted in a GitHub pull request

Clicking the link will open a branch deployment - or a preview of the changes - in Dagster Cloud.

Directly in Dagster Cloud#

You can also access branch deployments directly in Dagster Cloud from the deployment switcher:

Highlighted branch deployment in the Dagster Cloud deployment switcher

Best practices#

To ensure the best experience when using Branch Deployments, we recommend:

  • Configuring jobs based on environment. Dagster automatically sets environment variables containing deployment metadata, allowing you to parameterize jobs based on the executing environment. Use these variables in your jobs to configure things like connection credentials, database, and so on. This practice will allow you to use Branch Deployments without impacting production data.

  • Creating jobs to automate output cleanup. As Branch Deployments don't automatically remove the output they create, you may want to create an additional Dagster job to perform the cleanup.

Want some help with implementation? Check out the Testing against production with Dagster Cloud Branch Deployments guide for a step-by-step look at implementing these best practices in your own data pipelines.