Skip to main content

Default deploy action for deploying code to Astro

By default, the deploy action uses the infer deploy type, which enables the action to determine whether to use either a dags-only deploy or an image-and-dags deploy, depending on the files you change.

Prerequisites

Each CI/CD template implementation might have additional requirements.

warning

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.
info

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.

Setup

To automate code deploys to a single Deployment using GitHub Actions, 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.
  2. In your project repository, create a new YAML file in .github/workflows that includes the following configuration:

    name: Astronomer CI - Deploy code

    on:
    push:
    branches:
    - main

    env:
    ## Sets Deployment API credentials as environment variables
    ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}

    jobs:
    build:
    runs-on: ubuntu-latest
    steps:
    - name: Deploy to Astro
    uses: astronomer/deploy-action@v0.9.0
    with:
    deployment-id: <your-deployment-id>
  3. (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.

warning

Using wake-on-deploy takes precedence over any existing Deployment hibernation overrides that you configured through the Astro UI or config.yaml file.

Was this page helpful?