How to Publish Storybook to Chromatic in GitHub Actions
Chromatic turns Storybook into a visual diff on every PR, but it needs full git history to compute the baseline.
Check out with fetch-depth: 0, install dependencies, then run the chromaui/action with your project token to publish and diff.
Steps
- Store the Chromatic project token as
CHROMATIC_PROJECT_TOKEN. - Check out with
fetch-depth: 0so Chromatic can diff against the baseline. - Install dependencies.
- Run the
chromaui/action.
Workflow
.github/workflows/chromatic.yml
name: Chromatic
on: [push]
jobs:
chromatic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with: { node-version: '20' }
- run: npm ci
- uses: chromaui/action@latest
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}Notes
- Without
fetch-depth: 0Chromatic cannot find the baseline commit and re-snapshots everything. - Use
exitZeroOnChanges: trueif you do not want visual changes to fail the build.
Related guides
How to Run Accessibility Tests in GitHub ActionsRun automated accessibility checks in GitHub Actions with axe-core against a built site or running app so WCA…
How to Set Up Branch Deploy Previews with Vercel in GitHub ActionsBuild and deploy a Vercel preview per branch from GitHub Actions using the Vercel CLI, then surface the uniqu…