This documentation is for an older version (1.4.7) of Dagster. You can view the version of this page from our latest release below.
This guide is applicable to Dagster Cloud.
In this guide, we'll walk you through setting up Branch Deployments with GitHub Actions.
Using this approach to branch deployments may be a good fit if:
If you don't use GitHub for version control or want full control over your setup, check out the Branch deployments with the dagster-cloud CLI
guide.
To complete the steps in this guide, you'll need:
In this step, you'll generate a token for the Dagster Cloud agent. The Dagster Cloud agent will use this to authenticate to the agent API.
Keep the token somewhere handy - you'll need it to complete the setup.
If using Serverless deployment, this step isn't required.
While you can use your existing production agent, we recommend creating a dedicated branch deployment agent. This ensures that your production instance isn't negatively impacted by the workload associated with branch deployments.
Deploy an ECS agent to serve your branch deployments. Follow the ECS agent setup guide, making sure to set the Enable Branch Deployments parameter if using the CloudFormation template. If you are running an existing agent, follow the upgrade guide to ensure your template is up-to-date. Then, turn on the Enable Branch Deployments parameter.
Create a private Amazon Elastic Registry (ECR) repository. Refer to the AWS ECR documentation for instructions.
After the repository has been created, navigate back to the list of ECR repositories.
In the list, locate the repository and its URI:
Create an IAM user. This user must:
After the user is created, save the Access key ID and Secret access key values shown on the confirmation page:
Set up a new Docker agent. Refer to the Docker agent setup guide for instructions.
After the agent is set up, modify the dagster.yaml
file as follows:
dagster_cloud_api.branch_deployments
field to true
deployment
field(s)For example:
# dagster.yaml instance_class: module: dagster_cloud.instance class: DagsterCloudAgentInstance dagster_cloud_api: agent_token: <YOUR_AGENT_TOKEN> branch_deployments: true ## true enables branch deployments user_code_launcher: module: dagster_cloud.workspace.docker class: DockerUserCodeLauncher config: networks: - dagster_cloud_agent server_ttl: enabled: true ttl_seconds: 7200 #2 hours
Set up a new Kubernetes agent. Refer to the Kubernetes agent setup guide for instructions.
After the agent is set up, modify your Helm values file to include the following:
dagsterCloud: branchDeployments: true --- workspace: serverTTL: enabled: true ttlSeconds: 7200
If you used the GitHub app to add the repository as a code location, this step isn't required. Skip to the next step.
In this step, you'll add the required GitHub workflow files to your GitHub repository. The files can be found in our Hybrid quickstart repository or Serverless quickstart repository, depending on the agent you are using.
Copy the following files to your repository (the linked files are shown in the Hybrid repo, there are equivalents in the Serverless repo).
In the next step, you'll modify these files to work with your Dagster Cloud setup.
In this section, you'll:
dagster_cloud.yaml
If you're using Serverless deployment, this step isn't required. Skip to the next step.
In the dagster_cloud.yaml
file, replace build.registry
with the registry used by the agent you created in Step 2.
For example:
# dagster_cloud.yaml locations: - location_name: example_location code_source: python_file: repo.py build: directory: ./example_location registry: 764506304434.dkr.ecr.us-east-1.amazonaws.com/branch-deployment-agent
If you used the GitHub app to add the repository as a code location, this step isn't required.
Want to use secrets in your Dagster code? Check out the Dagster Cloud environment variables and secrets guide for more info.
API_TOKEN
For Hybrid deployments, repeat steps 3-6 for each of the secrets required for your registry type:
If you're using Serverless deployment, this step isn't required. Skip to the next step.
In this step, you'll update the GitHub Workflow files in the repository to set up Docker registry access.
In the .github/workflows/deploy.yml
and .github/workflows/branch_deployments.yml
files, uncomment the step
associated with your registry. For example, for an Amazon ECR registry, you'd uncomment the following portion of the workflow files:
steps: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ${{ secrets.AWS_REGION }}
Save and commit the files to the repository.
The last step is to verify that the Action runs successfully.
In the repository, click the Actions tab.
In the list of workflows, locate the latest branch deployment run. For example:
If the run finished successfully, that's it!
Now that Branch Deployments are configured, you can check out the preview in Dagster Cloud. There are two ways to do this:
Every pull request in the repository contains a View in Cloud link:
Clicking the link will open a branch deployment - or a preview of the changes - in Dagster Cloud.
You can also access branch deployments directly in Dagster Cloud from the deployment switcher: