From d0d95f401f51c2e19122a677b54c9f9fa8ca36a1 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Thu, 20 Jun 2024 22:39:46 +0200 Subject: [PATCH] add "Examples Only" version of Storybook and Chromatic --- .github/workflows/chromatic.yml | 14 ++++++++++++-- .storybook/main.ts | 8 +++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index 2de6957..70c80ab 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -30,8 +30,18 @@ jobs: run: > pnpm run build - - name: Publish to Chromatic - uses: chromaui/action@v1 + - name: Upload to Chromatic + uses: chromaui/action@v11 with: token: ${{ secrets.GITHUB_TOKEN }} projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} + onlyChanged: true + + - name: Upload "Examples" to Chromatic + uses: chromaui/action@v11 + env: + EXAMPLES_ONLY: true + with: + token: ${{ secrets.GITHUB_TOKEN }} + projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN_EXAMPLES_ONLY }} + onlyChanged: true diff --git a/.storybook/main.ts b/.storybook/main.ts index 789297b..eec39a4 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -1,18 +1,20 @@ import type { StorybookConfig } from '@storybook/svelte-vite'; +const examplesOnly = process.env.EXAMPLES_ONLY === 'true'; + const config: StorybookConfig = { stories: [ { directory: '../examples', files: '**/*.stories.@(ts|svelte)', - titlePrefix: 'Examples', + titlePrefix: examplesOnly ? undefined : 'Examples', }, - { + !examplesOnly && { directory: '../tests/stories', files: '**/*.stories.@(ts|svelte)', titlePrefix: 'Tests', }, - ], + ].filter(Boolean) as StorybookConfig['stories'], framework: '@storybook/svelte-vite', addons: ['../dist/preset.js', '@storybook/addon-essentials', '@storybook/addon-interactions'], };