CI/CD for a RedwoodJS App with GitHub Actions
Lint, test both sides, migrate Prisma, and build your RedwoodJS app.
RedwoodJS is a full-stack framework with a React web side and a GraphQL api side sharing one repo. This recipe runs yarn rw test for both sides against a Postgres service container, then builds the app.
What the pipeline does
- install deps with yarn install --immutable
- lint with yarn rw lint
- apply Prisma migrations to Postgres
- test web and api with yarn rw test
- build with yarn rw build
The workflow
Redwood uses Yarn workspaces. Enable Corepack so the pinned Yarn version is used, then run the Redwood CLI commands against a Postgres service.
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: redwood
ports: ["5432:5432"]
options: >-
--health-cmd "pg_isready" --health-interval 10s
--health-timeout 5s --health-retries 5
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/redwood
TEST_DATABASE_URL: postgresql://postgres:postgres@localhost:5432/redwood
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: corepack enable
- run: yarn install --immutable
- run: yarn rw lint
- run: yarn rw prisma migrate deploy
- run: yarn rw test --no-watch
- run: yarn rw buildCaching and speed
Cache the Yarn cache directory with actions/cache keyed on yarn.lock. Redwood builds both the web bundle and the api functions, which is heavy; running on cheaper managed runners such as Latchkey (around 69% cheaper than GitHub-hosted) keeps PR feedback fast, and auto-retry handles flaky dependency fetches.
Deploying
yarn rw build emits web/dist plus api function bundles. Use a Redwood deploy provider (Netlify, Vercel, or serverless) with yarn rw deploy, and run prisma migrate deploy against production first.
Key takeaways
- Enable Corepack so the pinned Yarn version drives the Redwood CLI.
- yarn rw test runs both web and api suites; pass --no-watch in CI.
- Build emits a web bundle plus api function bundles for serverless deploy.