For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
      • AstroFully-managed data operations, powered by Apache Airflow.
      • Astro Private CloudRun Airflow-as-a-service in your environment.
      • Professional ServicesExpert Airflow services for your enterprise's success.
    • Tools
      • Cosmos
      • Orbiter
      • CLI
      • AI SDK
      • Agents
      • Blueprint
      • UpdatesThe State of Airflow 2026See the insights from over 5,800 data practitioners in the full report. Download Now ➔
  • Customers
  • Docs
    • Insights
      • Blog
      • Webinars
      • Resource Library
      • Events
    • Education
      • Academy
      • What is Airflow?
  • Pricing
Get Started Free
    • Overview
      • Overview
      • Authenticate an automation tool
        • Develop a CI/CD workflow
          • Template options
          • Jenkins
          • GitLab
          • AWS S3 bucket
          • AWS CodeBuild
          • Azure DevOps
          • GCS bucket
          • Bitbucket
          • CircleCI
          • Drone
          • Harness
      • Astro Terraform Provider
    • Book Office Hours

Product

  • Platform Overview
  • Astro
  • Astro Observe
  • Astro Private Cloud
  • Security & Trust
  • Pricing

Tools & Services

  • Cosmos
  • Docs
  • Professional Services
  • Product Updates

Use Cases

  • AI Ops
  • Data Observability
  • ETL/ELT
  • ML Ops
  • Operational Analytics
  • All Use Cases

Industries

  • Financial Services
  • Gaming
  • Retail
  • Manufacturing
  • Healthcare
  • All Industries

Resources

  • Academy
  • eBooks & Guides
  • Blog
  • Webinars
  • Events
  • The Data Flowcast Podcast
  • All Resources

Airflow

  • What is Airflow
  • Airflow on Astro
  • Airflow 3.0
  • Airflow Upgrades
  • Airflow Use Cases
  • Airflow 2.x End of Life

Company

  • Our Story
  • Customers
  • Newsroom
  • Careers
  • Contact

Support

  • Knowledge Base
  • Status
  • Contact Support
GitHubYouTubeLinkedInx
  • Legal
  • Privacy
  • Terms of Service
  • Consent Preferences

  • Do Not Sell or Share My Personal information
  • Limit the Use Of My Sensitive Personal Information

Apache Airflow®, Airflow, and the Airflow logo are trademarks of the Apache Software Foundation. Copyright © Astronomer 2026. All rights reserved.

LogoLogo
On this page
  • Prerequisites
  • Image deploy templates
  • Dag deploy templates
  • Single branch implementation
Automation & CI/CDCI/CDCI/CD templates

Astro CI/CD templates for GitLab

Edit this page
Built with

Use the following CI/CD templates to automate deploys to Astro from a GitLab repository.

Read the following sections to choose the right template for your project. The templates for GitLab include the image deploy templates and dag deploy templates.

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 you want your CI/CD process to automatically decide which deploy strategy to choose, see Dag deploy templates.

To learn more about CI/CD on Astro, see Choose a CI/CD strategy.

Prerequisites

  • An Astro project hosted in a GitLab repository.
  • An Astro Deployment.
  • A Deployment API token, Workspace API token, or Organization API token.

Each CI/CD template implementation might have additional requirements.

Image deploy templates

Single branch
Multiple branch

Use this template to push code from a GitLab repository to Astro.

  1. Set the following environment variables in your GitLab project:
  • ASTRO_API_TOKEN: The value for your Workspace or Organization API token.
  • DEPLOYMENT_ID: The ID of your Astro Deployment. You can copy the ID from your Deployment’s home page in the Astro UI.

Astronomer recommends that you always mask your API token to prevent it from being accessible in plain text. You can also set the API token as an external secret for an extra layer of security.

  1. Go to Build > Pipeline Editor and commit the following:
1astro_deploy:
2 stage: deploy
3 image: docker:latest
4 services:
5 - docker:dind
6
7 variables:
8 ASTRO_API_TOKEN: ${ASTRO_API_TOKEN}
9 DEPLOYMENT_ID: ${DEPLOYMENT_ID}
10
11 before_script:
12 - apk add --update curl && rm -rf /var/cache/apk/*
13 - apk add bash
14 script:
15 - (curl -sSL install.astronomer.io | bash -s)
16 - astro deploy -f $DEPLOYMENT_ID
17 only:
18 - main

Dag deploy templates

The dag deploy template uses the --dags flag in the Astro CLI to push dag changes to Astro. These CI/CD pipelines deploy your dags only when files in your dags folder are modified, and they deploy the rest of your Astro project as a Docker image when other files or directories are modified. For more information about the benefits of this workflow, see Deploy dags only.

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.

Single branch implementation

Use this template to push code from a GitLab repository to Astro.

  1. Set the following environment variables in your GitLab project:
  • ASTRO_API_TOKEN: The value for your Workspace or Organization API token.
  • DEPLOYMENT_ID: The ID of your Astro Deployment. You can copy the ID from your Deployment’s page in the Astro UI.

Astronomer recommends that you always mask your API token to prevent it from being accessible in plain text. You can also set the API token as an external secret for an extra layer of security.

  1. Go to the Editor option in your project’s CI/CD section and commit the following:
1astro_smart_deploy:
2 stage: deploy
3 image: docker:latest
4 services:
5 - docker:dind
6 variables:
7 ASTRO_API_TOKEN: ${ASTRO_API_TOKEN}
8 DAG_FOLDER: "dags"
9 DEPLOYMENT_ID: ${DEPLOYMENT_ID}
10 before_script:
11 - apk add --update curl && rm -rf /var/cache/apk/*
12 - apk add git
13 - apk add bash
14 script:
15 - (curl -sSL install.astronomer.io | bash -s)
16 - files=$(git diff --name-only $(git rev-parse HEAD~1) -- .)
17 - dags_only=1
18 - echo "$DAG_FOLDER"
19 - echo "$files"
20 - for file in $files; do
21 - echo "$file"
22 - if [[ "$file" != "$DAG_FOLDER"* ]]; then
23 - echo "$file is not a dag, triggering a full image build"
24 - dags_only=0
25 - break
26 - else
27 - echo "just a dag"
28 - fi
29 - done
30 - if [[ $dags_only == 1 ]]; then
31 - echo "doing dag-only deploy"
32 - astro deploy --dags $DEPLOYMENT_ID
33 - elif [[ $dags_only == 0 ]]; then
34 - echo "doing image deploy"
35 - astro deploy -f $DEPLOYMENT_ID
36 - fi
37 only:
38 - main