> ## Documentation Index
> Fetch the complete documentation index at: https://astronomer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Astro CI/CD templates for Bitbucket

Use the following CI/CD templates to automate deploying Apache Airflow dags from a Git repository to Astro with [Bitbucket](https://bitbucket.org/product).

The templates for Bitbucket use the [image deploy](/docs/astro/ci-cd-templates/template-overview) process with a [single branch implementation](#single-branch-implementation), which requires only one Astro Deployment.

If you use the [dag-only deploy feature](/docs/astro/deploy-dags) on Astro or you're interested in a multiple-branch implementation, see [Template overview](/docs/astro/ci-cd-templates/template-overview#multiple-branch-implementation) to configure your own. To learn more about CI/CD on Astro, see [Choose a CI/CD strategy](/docs/astro/set-up-ci-cd).

## Prerequisites

* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) hosted in a Git repository that Bitbucket can access.
* An [Astro Deployment](/docs/astro/create-deployment).
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens).
* Access to [Bitbucket](https://bitbucket.org/product).

## Single branch implementation

To automate code deploys to a Deployment using [Bitbucket](https://bitbucket.org/), complete the following setup in a Git-based repository that hosts an Astro project:

1. Set the following environment variable as a [Bitbucket pipeline variable](https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/):

   * `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
   * `ASTRO_DEPLOYMENT_ID`: Your Deployment ID.

   For production Deployments, be sure to set the value of your API token as **secured**.

2. Create a new YAML file in `bitbucket-pipelines.yml` at the root of the repository that includes the following configuration:

   ```yaml title="bitbucket-pipelines.yml" wrap theme={null}
   pipelines:
     pull-requests: # The branch pattern under pull requests defines the *source* branch.
       dev:
         - step:
             name: Deploy to Production
             deployment: Production
             script:
               - curl -sSL install.astronomer.io | sudo bash -s
               - astro deploy ${ASTRO_DEPLOYMENT_ID} -f
             services:
               - docker
   ```
