68 lines
1.9 KiB
YAML
68 lines
1.9 KiB
YAML
---
|
|
name: Chromatic
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "main"
|
|
- "rc"
|
|
- "hotfix-rc"
|
|
pull_request_target:
|
|
types: [opened, synchronize]
|
|
|
|
jobs:
|
|
check-run:
|
|
name: Check PR run
|
|
uses: bitwarden/gh-actions/.github/workflows/check-run.yml@main
|
|
|
|
chromatic:
|
|
name: Chromatic
|
|
runs-on: ubuntu-22.04
|
|
needs: check-run
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- name: Check out repo
|
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
fetch-depth: 0
|
|
|
|
- name: Get Node version
|
|
id: retrieve-node-version
|
|
run: |
|
|
NODE_NVMRC=$(cat .nvmrc)
|
|
NODE_VERSION=${NODE_NVMRC/v/''}
|
|
echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT
|
|
|
|
- name: Set up Node
|
|
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
|
|
with:
|
|
node-version: ${{ steps.retrieve-node-version.outputs.node_version }}
|
|
|
|
- name: Cache NPM
|
|
id: npm-cache
|
|
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
|
|
with:
|
|
path: "~/.npm"
|
|
key: ${{ runner.os }}-npm-chromatic-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
- name: Install Node dependencies
|
|
run: npm ci
|
|
|
|
# Manually build the Storybook to resolve a bug related to TurboSnap
|
|
- name: Build Storybook
|
|
run: npm run build-storybook:ci
|
|
|
|
- name: Publish to Chromatic
|
|
uses: chromaui/action@b984808b772126a9f44b2b7737b131b68a2ede32 # v11.7.1
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
|
|
storybookBuildDir: ./storybook-static
|
|
exitOnceUploaded: true
|
|
onlyChanged: true
|
|
externals: "[\"libs/components/**/*.scss\", \"libs/components/**/*.css\", \"libs/components/tailwind.config*.js\"]"
|