---
title: "Create a database branch with GitHub Actions"
description: "A GitHub Actions workflow triggered on branch creation can call the Turso Platform API to seed a new database from an existing one, giving each Git branch its own isolated database."
url: "https://swe.quest/articles/create-a-database-branch-with-github-actions-d979dde1d3eb17f6"
canonical: "https://turso.tech/blog/create-a-database-branch-with-github-actions-07bbf804"
source: "Turso"
published: "2024-01-18"
difficulty: "medium"
kind: "How-to"
reading_minutes: 5
tags: ["ci-cd","sqlite","databases"]
---

# Create a database branch with GitHub Actions

A post on [Turso](https://swe.quest/sources/turso.md), published 2024-01-18, 5 min read, How-to. Original: [https://turso.tech/blog/create-a-database-branch-with-github-actions-07bbf804](https://turso.tech/blog/create-a-database-branch-with-github-actions-07bbf804)

## Summary

A GitHub Actions workflow triggered on branch creation can call the Turso Platform API to seed a new database from an existing one, giving each Git branch its own isolated database. The workflow stores the API token, organization, group and source database name as repository secrets and names the new database after \`github.ref\_name\`. It uses \`curl -f\` with exit-code checks to fail the job on API errors, then extracts the returned Hostname with \`jq\` and exports it to \`GITHUB\_ENV\` for later steps such as deployments. Branch names must contain only lowercase letters, numbers and hyphens to be valid database names, and the official \`tursodatabase/create-database-action\` wraps the same logic.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)
- [SQLite](https://swe.quest/tags/sqlite.md) (Data & databases)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)

## Prerequisites

- GitHub Actions workflows ([easy posts on CI/CD](https://swe.quest/tags/ci-cd.md?difficulty=easy))
- bash and curl

## Keywords

Turso, GitHub Actions, Turso Platform API, jq, libSQL

## Related posts

- [Branching Postgres databases with the Neon API](https://swe.quest/articles/branching-postgres-databases-with-the-neon-api-3faf0de941bc811a.md): Neon · 2022-12-07 · Medium · 3 min read · PostgreSQL, CI/CD, Testing
  Neon branches are copy-on-write clones of a Postgres database that can be created and deleted through the Neon API, giving CI pipelines an isolated copy of production data for end-to-end tests.
- [Supabase Branching](https://swe.quest/articles/supabase-branching-4fbb0c9896d51627.md): Supabase · 2023-12-13 · Medium · 5 min read · Schema migrations, PostgreSQL, CI/CD, Deployment
  Supabase Branching gives each Git branch an isolated hosted Preview environment with its own Postgres database, Auth, Storage, Realtime, Edge Functions and APIs, plus separate credentials.
- [Database migrations with Geni and libSQL](https://swe.quest/articles/database-migrations-with-geni-and-libsql-3a27c6420a1aefca.md): Turso · 2024-08-05 · Medium · 3 min read · Schema migrations, SQLite, CI/CD
  Geni is a lightweight CLI that manages schema changes as paired up/down SQL files, applying each migration inside a transaction so a failed migration leaves the database unchanged.
- [Adopting Neon branching in CI/CD pipelines: a practical story by Shepherd](https://swe.quest/articles/adopting-neon-branching-in-ci-cd-pipelines-a-practical-story-by-shepherd-7c4ee09d2fb5431a.md): Neon · 2024-07-11 · Medium · 5 min read · CI/CD, PostgreSQL, Schema migrations, Testing, Serverless
  Shepherd, an insurtech startup that moved its Alchemist pricing engine from SQLite to Postgres, uses Neon's copy-on-write database branches to give every pull request an ephemeral test database.
- [Vercel setup guide](https://swe.quest/articles/vercel-setup-guide-deae2ea282865eb4.md): Turso · 2023-04-11 · Medium · 5 min read · SQLite, Deployment, Serverless, JavaScript
  Deploying a Nuxt app backed by a Turso database to Vercel comes down to two environment variables, NUXT\_TURSO\_DB\_URL and NUXT\_TURSO\_DB\_AUTH\_TOKEN, which the libSQL TypeScript client uses to connect.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
