Astronomer CI/CD templates are customizable, pre-built code samples that help you configure automated workflows with popular CI/CD tools, such as GitHub Actions or Jenkins. Use the templates to create a workflow that automates deploying code to Astro according to your team’s CI/CD requirements and strategy. Template types differ based on the deploy method they use and how many branches or environments they require. This document contains information about the following template types:Documentation Index
Fetch the complete documentation index at: https://astronomer-preview.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
- Dag deploy templates that use the dag-only deploy feature in Astro and either deploy dags or your entire Astro project depending on the files that you update.
- dbt deploy templates that use the dbt deploy feature in Astro to push dbt code from your specified dbt project directory, by default
/dbt, to make the code accessible in your Deployment. - Image deploy templates that build a Docker image and push it to Astro whenever you update any file in your Astro project, including your dag directory.
- Preview Deployment templates that automatically create and delete Deployments when you create or delete a feature branch from your main Astro project branch.
Dag deploy templates
Dag deploy templates check the changes in your Astro project and trigger either a dag deploy or image deploy based on the files changed, allowing for faster deploys. This template deploys your dags when only the files in yourdags folder are modified, and it deploys the rest of your Astro project as a Docker image when any other files or directories are modified. To learn more about the benefits of this workflow, see Deploy dags.
CI/CD templates that use the dag deploy workflow:
- Require that each Deployment have the dag-only deploy feature enabled. See Enable/disable dag-only deploys on a Deployment.
- Use a Deployment API token, Workspace API token, or Organization API token. This value must be set using the
ASTRO_API_TOKENenvironment variable. - Install the latest version of the Astro CLI.
- Trigger the following Astro CLI commands depending on which files were updated by the commit:
- If only dag files in the
dagsfolder have changed, runastro deploy --dags. This pushes yourdagsfolder to your Deployment. - If any file not in the
dagsfolder has changed, runastro deploy. This triggers two subprocesses. One that creates a Docker image for your Astro project, authenticates to Astro using your Deployment API token, and pushes the image to your Deployment. A second that pushes yourdagsfolder to your Deployment.
- If only dag files in the
If you stage multiple commits to dag files and push them all at once to your remote branch, the template only deploys dag code changes from the most recent commit. It will miss any code changes made in previous commits.To avoid this, either push commits individually or configure your repository to Squash commits for pull requests that merge multiple commits simultaneously.
Image deploy templates
Image based templates build a Docker image and push it to Astro whenever you update any file in your Astro project. This type of template works well for development workflows that include complex Docker customization or logic. CI/CD templates that use image based workflows:- Use a Deployment API token, Workspace API token or Organization API token. This value must be set using the
ASTRO_API_TOKENenvironment variable. - Install the latest version of the Astro CLI.
- Run the
astro deploycommand. This creates a Docker image for your Astro project, authenticates to Astro using your Deployment API token, and pushes the image to your Deployment.
dbt deploy templates
dbt deploy templates use dbt deploy to deploy just your dbt code to your Astro project, allowing for faster deploys. Or, it uses the Deploy Action with GitHub Actions to deploy dbt code. These templates deploy your dbt code when only the files in your dbt project folder, by default/dbt, are modified.
CI/CD templates that use image based workflows:
- Use a Deployment API token, Workspace API token or Organization API token. This value must be set using the
ASTRO_API_TOKENenvironment variable. - Install the latest version of the Astro CLI.
- Run the
astro dbt deploycommand from your dbt project directory. This bundles all files in your dbt project and pushes them to Astro, where they are mounted on your Airflow containers so that your dags can access them.
Preview Deployment templates
Preview Deployment templates enable a CI/CD workflow that automates creating and deleting Deployments based on feature branches in your Git repository. A preview Deployment is automatically created when the temporary feature branch is created and the Deployment is deleted when the branch is deleted. Astronomer recommends using preview Deployments if you regularly need to test a small set of dags on Astro before promoting those dags to a base, production Deployment. This helps you lower the infrastructure cost of Deployments that are dedicated to development and testing. To implement this feature, you need a CI/CD workflow that:- Creates the preview Deployment when you create a new branch.
- Deploys code changes to Astro when you make updates in the branch.
- Deletes the preview Deployment when you delete the branch.
- Deploys your changes to your base Deployment after you merge your changes into your main branch.