Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Configure and optimize Turborepo monorepo build pipelines with correct task structure, caching, and CI setup.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/ci/github-actions.md
1# GitHub Actions23Complete setup guide for Turborepo with GitHub Actions.45## Basic Workflow Structure67```yaml8name: CI910on:11push:12branches: [main]13pull_request:14branches: [main]1516jobs:17build:18runs-on: ubuntu-latest19steps:20- uses: actions/checkout@v421with:22fetch-depth: 22324- uses: actions/setup-node@v425with:26node-version: 202728- name: Install dependencies29run: npm ci3031- name: Build and Test32run: turbo run build test lint33```3435## Package Manager Setup3637### pnpm3839```yaml40- uses: pnpm/action-setup@v341with:42version: 94344- uses: actions/setup-node@v445with:46node-version: 2047cache: "pnpm"4849- run: pnpm install --frozen-lockfile50```5152### Yarn5354```yaml55- uses: actions/setup-node@v456with:57node-version: 2058cache: "yarn"5960- run: yarn install --frozen-lockfile61```6263### Bun6465```yaml66- uses: oven-sh/setup-bun@v167with:68bun-version: latest6970- run: bun install --frozen-lockfile71```7273## Remote Cache Setup7475### 1. Create Vercel Access Token76771. Go to [Vercel Dashboard](https://vercel.com/account/tokens)782. Create a new token with appropriate scope793. Copy the token value8081### 2. Add Secrets and Variables8283In your GitHub repository settings:8485**Secrets** (Settings > Secrets and variables > Actions > Secrets):8687- `TURBO_TOKEN`: Your Vercel access token8889**Variables** (Settings > Secrets and variables > Actions > Variables):9091- `TURBO_TEAM`: Your Vercel team slug9293### 3. Add to Workflow9495```yaml96jobs:97build:98runs-on: ubuntu-latest99env:100TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}101TURBO_TEAM: ${{ vars.TURBO_TEAM }}102```103104## Alternative: actions/cache105106If you can't use remote cache, cache Turborepo's local cache directory:107108```yaml109- uses: actions/cache@v4110with:111path: .turbo112key: turbo-${{ runner.os }}-${{ hashFiles('**/turbo.json', '**/package-lock.json') }}113restore-keys: |114turbo-${{ runner.os }}-115```116117Note: This is less effective than remote cache since it's per-branch.118119## Complete Example120121```yaml122name: CI123124on:125push:126branches: [main]127pull_request:128branches: [main]129130jobs:131build:132runs-on: ubuntu-latest133env:134TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}135TURBO_TEAM: ${{ vars.TURBO_TEAM }}136137steps:138- uses: actions/checkout@v4139with:140fetch-depth: 2141142- uses: pnpm/action-setup@v3143with:144version: 9145146- uses: actions/setup-node@v4147with:148node-version: 20149cache: "pnpm"150151- name: Install dependencies152run: pnpm install --frozen-lockfile153154- name: Build155run: turbo run build --affected156157- name: Test158run: turbo run test --affected159160- name: Lint161run: turbo run lint --affected162```163