On this page

CI and GitHub Actions

Deploy migrations and functions from CI, and give every pull request its own preview branch with GitHub Actions.

#GitHub Actions

Terminal
stitchdb init --github

writes .github/workflows/stitchdb.yml. Then, in your repository settings, add the secret STITCHDB_ACCESS_TOKEN (a read-write access token) and the variable STITCHDB_PROJECT_REF (your production project). The workflow:

WhenWhat happens
A pull request is opened or updatedA preview branch named after the git branch is created (or reused), the PR's migrations are pushed and its functions deployed, and the PR gets a comment with the branch URL
The pull request is closed or mergedThe preview branch is deleted
A commit lands on mainMigrations are pushed to production and functions deployed

#Any other CI

Set STITCHDB_ACCESS_TOKEN and STITCHDB_PROJECT_REF, install the CLI, and run the commands non-interactively:

Terminal
npm install -g stitchdb-cli
stitchdb db push --yes
stitchdb functions deploy --all --if-present
stitchdb gen types typescript > src/database.types.ts

Every command exits with a non-zero status when it fails, and --json prints machine-readable output. Use an access token limited to the project you deploy (Account → Access tokens → Projects).