Chromatic deployment for bordered-button #21792
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Chromatic" | |
run-name: Chromatic deployment for ${{ github.event.workflow_run.head_branch }} | |
on: | |
workflow_run: | |
workflows: ["Build Storybook"] | |
types: | |
- completed | |
jobs: | |
chromatic-deployment: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
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: "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); | |
const base = fs.readFileSync("./METADATA/base", "utf8").trim(); | |
core.setOutput("base", base); | |
- name: Fetch base branch from upstream | |
if: github.event.workflow_run.event == 'pull_request' | |
run: | | |
git remote add upstream ${{ github.event.repository.clone_url }} | |
git fetch upstream | |
git checkout -B ${{ steps.chromatic_branch.outputs.base }} upstream/${{ steps.chromatic_branch.outputs.base }} | |
git checkout ${{ github.event.workflow_run.head_branch }} | |
git clean -ffdx && git reset --hard HEAD | |
- 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: Publish to Chromatic | |
if: ${{ steps.chromatic_branch.outputs.draft != 'true' }} | |
uses: chromaui/action@v11.3.5 | |
# 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)/**' || '' }} | |
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 }} | |
debug: true | |
env: | |
LOG_LEVEL: "debug" |