dbt deploy action for deploying dbt code to Astro

There is a hard limit of 10 dbt bundles per Astro Deployment

If you have a dbt project that you want to use with the deploy action for a GitHub action, you can choose to use either the dbt deploy on its own, or you can create GitHub actions that combine the infer action with a dbt deploy.

Prerequisites

Each CI/CD template implementation might have additional requirements.

If you use a self-hosted runner to execute jobs from GitHub Actions, the Astro CLI’s config.yaml file, which stores default deploy details, might be shared across your organization and hence multiple CI/CD pipelines. To reduce the risk of accidentally deploying to the wrong Deployment, ensure the following:

  • Add ASTRO_API_TOKEN to your repository and include a check in your GitHub workflow to verify that it exists.
  • Use Deployment API tokens, which are scoped only to one Deployment, instead of Workspace or Organization API tokens.
  • Specify deployment-id or deployment-name in your action. For example, astro deploy <deployment-id> or astro deploy -n <deployment-name>.
  • Add the command astro logout at the end of your workflow to ensure that your authentication token is cleared from the config.yaml file

Setup

Each template installs the Astro CLI with setup-astro-cli before deploy-action runs. Astronomer recommends installing the CLI in a separate step so that you can pin or upgrade the CLI version independently of the action, including with Dependabot, and reuse a single installation across multiple deploy steps. To pin a version, set the version input, for example version: "1.40.1". If you omit this step, deploy-action installs the latest version of the Astro CLI itself.

Prerequisites

  • The root folder name for the directory that contains your dbt project.

Implementation

To automate code deploys to a single Deployment using GitHub Actions for a dbt project, complete the following setup in a Git-based repository that hosts an Astro project:

  1. Set the following as a GitHub secret:
  • ASTRO_API_TOKEN: The value for your Workspace or Organization API token.
  1. In your project repository, create a new YAML file in .github/workflows that includes the following configuration:
1name: Astronomer CI - Deploy dbt code
2
3on:
4 push:
5 branches:
6 - main
7
8env:
9 ## Sets Deployment API credentials as environment variables
10 ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
11
12jobs:
13 build:
14 runs-on: ubuntu-latest
15 steps:
16 - name: Install Astro CLI
17 uses: astronomer/setup-astro-cli@v0.0.1
18 - name: Deploy to Astro
19 uses: astronomer/deploy-action@v0.13.0
20 with:
21 deployment-id: <deployment id>
22 deploy-type: dbt
23 root-folder: <dbt-root-folder>
  1. (Optional) You can add optional configurations to customize your workflow. For example, if you add wake-on-deploy to your configuration, the Deploy Action wakes a hibernating Deployment before deploying code to it.
Using wake-on-deploy takes precedence over any existing Deployment hibernation overrides that you configured through the Astro UI or config.yaml file.