Astro CI/CD templates for CircleCI
Astro CI/CD templates for CircleCI
Astro CI/CD templates for CircleCI
CircleCI is a continuous integration and continuous delivery platform that can be used to implement DevOps practices. This document provides sample CI/CD templates to automate deploying Apache Airflow dags from a GitHub repository to Astro using CircleCI.
If you have one Deployment and one environment on Astro, use the single branch implementation. If you have multiple Deployments that support development and production environments, use the multiple branch implementation. If your team builds custom Docker images, use the custom image implementation.
Refer to Template overview to see generic templates expressed as simple shell scripts or configure your own. To learn more about CI/CD on Astro, see Choose a CI/CD strategy.
Image deploy templates build a Docker image and push it to Astro whenever you update any file in your Astro project.
To automate code deploys to a Deployment using CircleCI for a single branch implementation, complete the following setup in a Git-based repository that hosts an Astro project:
main branch of an Astro project hosted in a single GitHub repository.main GitHub branch.ASTRO_API_TOKEN: The value for your Workspace or Organization API token.ASTRO_DEPLOYMENT_ID: The ID for your Deployment..circleci/config.yml that includes the following configuration:A dag deploy template uses the --dags flag in the astro deploy command in the Astro CLI to push only dags to your Deployment.
This CI/CD pipeline deploys your dags to Astro when one or more files in your dags folder are modified. It deploys the rest of your Astro project as a Docker image when other files or directories are also modified. For more information about the benefits of this workflow, see Deploy dags only.
For each Deployment that you use with dag deploy templates, you must enable dag deploys.
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.
To automate code deploys to a Deployment using CircleCI, complete the following setup in a Git-based repository that hosts an Astro project:
ASTRO_API_TOKEN: The value for your Workspace or Organization API token.ASTRO_DEPLOYMENT_ID: The ID for your Deployment..circleci/config.yml that includes the following configuration:This script checks the diff between your current commit and the HEAD of your branch to which you are pushing the changes to. If the changes are only in dags then it executes a dag-only deploy. Otherwise, it executes an image-based deploy. Make sure to customize the script to use your specific branch and context.
You can customize this script to work for multiple branches as shown in the image-based multi-branch deploy template by creating separate job and workflow for each branch.