Skip to content

Chromatic deployment for theme-json-theme-2.0 #20721

Chromatic deployment for theme-json-theme-2.0

Chromatic deployment for theme-json-theme-2.0 #20721

Workflow file for this run

name: "Chromatic"
run-name: Chromatic deployment for ${{ github.event.workflow_run.head_branch }}
on:
workflow_run:
workflows: ["Build Storybook"]
types:
- completed
jobs:
chromatic-deployment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ github.event.workflow_run.head_repository.full_name }}
ref: ${{ github.event.workflow_run.head_branch }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"
- name: Install dependencies
run: yarn
- name: "Download build artifact"
uses: actions/download-artifact@v4
with:
name: storybook-build
path: ./storybook-static
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: "Download chromatic branch name artifact"
uses: actions/download-artifact@v4
with:
name: metadata
path: ./METADATA
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Get branch for Chromatic
uses: actions/github-script@v7
id: chromatic_branch
with:
script: |
const fs = require("fs");
const branchName = fs.readFileSync("./METADATA/branch-name", "utf8").trim();
core.setOutput("branchName", branchName);
const draft = fs.readFileSync("./METADATA/draft", "utf8").trim();
core.setOutput("draft", draft);
- name: Publish to Chromatic
if: ${{ steps.chromatic_branch.outputs.draft != 'true' }}
uses: chromaui/action@v11
# Chromatic GitHub Action options
with:
# 👇 Chromatic projectToken, refer to the manage page to obtain it.
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
exitOnceUploaded: true
# Turbosnap if this is not the main branch
onlyChanged: ${{ steps.chromatic_branch.outputs.branchName != 'main' }}
externals: ${{ steps.chromatic_branch.outputs.branchName != 'main' && 'packages/(theme|ag-grid-theme)/**' || '' }}
skip: "changeset-release/*"
autoAcceptChanges: ${{ steps.chromatic_branch.outputs.branchName == 'main' }}
ignoreLastBuildOnBranch: "**"
traceChanged: ${{ steps.chromatic_branch.outputs.branchName != 'main' && 'expanded' || '' }}
storybookBuildDir: "./storybook-static"
branchName: ${{ steps.chromatic_branch.outputs.branchName }}