Deploying to Tinybird through CI

After you create your data project in Git, you can implement continuous integration (CI) workflows to automate interaction with Tinybird.

When you create a project using tb create, Tinybird generates CI templates you can use in GitHub and GitLab to automate testing and deployment.

The Tinybird Local container is a key part of the CI workflow. See Local container for more information.

CI workflow

As you expand and iterate on your data projects, you can continuously validate your changes. In the same way that you write integration and acceptance tests for source code in a software project, you can write automated tests for your API Endpoints to run on each pull or merge request.

A potential CI workflow could run the following steps when you open a pull request:

  1. Install Tinybird CLI: Sets up dependencies and installs the Tinybird CLI to run the required commands.
  2. Build project: Checks the datafile syntax and correctness.
  3. Test project: Runs fixture tests, data quality tests, or both to validate changes.

CI templates

The following templates are available for GitHub and GitLab:

name: Tinybird - CI Workflow

on:
  workflow_dispatch:
  pull_request:
    branches:
      - main
      - master
    types: [opened, reopened, labeled, unlabeled, synchronize]

concurrency: ${{ github.workflow }}-${{ github.event.pull_request.number }}

env:
  TINYBIRD_HOST: ${{ secrets.TINYBIRD_HOST }}
  TINYBIRD_TOKEN: ${{ secrets.TINYBIRD_TOKEN }}

jobs:
  ci:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: '.'
    services:
      tinybird:
        image: tinybirdco/tinybird-local:beta
        ports:
          - 7181:7181
    steps:
      - uses: actions/checkout@v3
      - name: Install Tinybird CLI
        run: curl -L https://tinybird.co | sh
      - name: Build project
        run: tb build
      - name: Test project
        run: tb test run
      - name: Deployment check
        run: tb --cloud --host ${{ TINYBIRD_HOST }} --token ${{ TINYBIRD_TOKEN }} deploy --check

Make sure to provide the values for the following secrets in your CI/CD settings:

  • TINYBIRD_HOST
  • TINYBIRD_TOKEN

Run tb auth info to get the values for the secrets. For example:

tb auth info

------------------------------------------------------------------------------------------------------------------------
user: user@tinybird.co
user_token: <user_token>
token: <token>
host: https://api.europe-west2.gcp.tinybird.co
ui: https://cloud.tinybird.co/gcp/europe-west2
workspace_name: demo_ws
workspace_id: <workspace_id>
------------------------------------------------------------------------------------------------------------------------

Next steps

Updated