Github Integration

The Github Integration allows you to automatically upload your schema to the tRPC Drift platform when you push to your Github repository.

Generate an API key

To hook up your Github repository to the tRPC Drift platform, you first need to generate an API key that will authenticate the action on your behalf.

In the tRPC Drift dashboard, go to your project, and select the API Keys tab. Click the Create API Key button.

Give the API key a name, and give it an expiration date (recommended).

Copy the API key and add it as a repository secret in your Github repository. You can do this by going to your repository, clicking Settings, and then Secrets. Click New repository secret and paste the API key in the Value field.

Create a Github Action

Next, we'll create a new workflow that runs on every push to main and uploads your schema to the tRPC Drift platform.

The exact workflow might differ depending on your project setup, but it should look something like this:

.github/workflows/trpc.yml
name: Upload Schema to tRPC Drift Dashboard
 
on:
  pull_request:
    branches: ["*"]
    types: [opened, synchronize, reopened, edited, closed] # <--- **IMPORTANT** to subscribe to these events
  push:
    branches: ["main"]
 
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 5 # <--- **IMPORTANT**, has to be >= 3. Give us some history to work with
 
      - uses: pnpm/action-setup@v2.2.4
      - uses: actions/setup-node@v3
        with:
          node-version: 18
          cache: pnpm
 
      - name: Install dependencies
        run: pnpm install
 
      - name: Upload schema
        run: pnpm trpc upload -vv # optional: -vv for verbose output
        env:
          API_KEY: ${{ secrets.DRIFT_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
.github/workflows/trpc.yml
name: Upload Schema to tRPC Drift Dashboard
 
on:
  pull_request:
    branches: ["*"]
    types: [opened, synchronize, reopened, edited, closed] # <--- **IMPORTANT** to subscribe to these events
  push:
    branches: ["main"]
 
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 5 # <--- **IMPORTANT**, has to be >= 3. Give us some history to work with
 
      - uses: pnpm/action-setup@v2.2.4
      - uses: actions/setup-node@v3
        with:
          node-version: 18
          cache: pnpm
 
      - name: Install dependencies
        run: pnpm install
 
      - name: Upload schema
        run: pnpm trpc upload -vv # optional: -vv for verbose output
        env:
          API_KEY: ${{ secrets.DRIFT_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Push changes

Now you can start pushing changes to your repository. The workflow will run on every push to main as well as on pull requests and upload your schema to the tRPC Drift platform. In the dashboard, you can see the latest schema ingestions and browse the schema history.