Skip to content

Visual Test

Visual Test #188

Workflow file for this run

name: Visual Test
on:
schedule:
- cron: '00 04 * * *' # Runs at midnight UTC every day
push:
branches:
- main
paths-ignore:
- '*.md'
- '*/*.md'
- '.devcontainer/**'
permissions:
contents: read
jobs:
chromatic:
name: Chromatic
runs-on: ubuntu-latest
steps:
- name: Harden the runner
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
chromatic-builds.s3.us-west-2.amazonaws.com:443
github.com:443
index.chromatic.com:443
nodejs.org:443
release-assets.githubusercontent.com:443
objects.githubusercontent.com:443
registry.npmjs.org:443
storybook.js.org:443
- name: Checkout the repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- name: Check if should run
id: should_run
run: |
if [ "${{ github.event_name }}" == "push" ]; then
if git log -1 --pretty=%B | grep -i "Chromatic"; then
echo "should_run=true" >> "$GITHUB_OUTPUT"
else
echo "should_run=false" >> "$GITHUB_OUTPUT"
fi
else
now=$(date -u +%s)
twenty_four_hours_ago=$((now - 86400))
last_commit_time=$(git log -1 --format=%ct)
if [ "$last_commit_time" -ge "$twenty_four_hours_ago" ]; then
echo "should_run=true" >> "$GITHUB_OUTPUT"
else
echo "should_run=false" >> "$GITHUB_OUTPUT"
fi
fi
- name: Install pnpm
if: steps.should_run.outputs.should_run == 'true'
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
with:
version: 10
- name: Install Node.js
if: steps.should_run.outputs.should_run == 'true'
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: 24
cache: pnpm
- name: Install dependencies
if: steps.should_run.outputs.should_run == 'true'
run: pnpm install --ignore-scripts
- name: Publish to Chromatic
if: steps.should_run.outputs.should_run == 'true'
uses: chromaui/action@4ffe736a2a8262ea28067ff05a13b635ba31ec05 # v13.3.0
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
buildScriptName: build-visual
exitZeroOnChanges: true
exitOnceUploaded: true
env:
STORYBOOK: '1'