Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/scripts/chromatic-comment.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = async ({ github, context, core }) => {
const hasChanges = process.env.HAS_CHANGES === 'true';
const changeCount = parseInt(process.env.CHANGE_COUNT || '0', 10);
const hasChanges = changeCount > 0;
const buildStatus = process.env.BUILD_STATUS || 'success'; // ← 이 줄 추가!
const storybookUrl = process.env.STORYBOOK_URL || '';
const buildUrl = process.env.BUILD_URL || '';
Expand Down Expand Up @@ -56,13 +57,13 @@ build log를 확인하시고 로직을 수정해주세요.
// Story 변경사항 없음
comment = `## 🎨 Storybook Report

ℹ️ **Story 변경사항이 감지되지 않았습니다**
**변경 사항이 없습니다**

이 PR에는 Story 변경이 없어서 빌드를 스킵했습니다.
모든 Story가 이전 빌드와 동일합니다.

| Status | Storybook | Build Log | Updated (UTC) |
|--------|-----------|-----------|---------------|
| ⏭️ Skipped | - | - | ${now} |`;
| ✅ Unchanged | [View Storybook](${storybookUrl}) | [View Build](${buildUrl}) | ${now} |`;
} else {
// Story 변경사항 있음
comment = `## 🎨 Storybook Report
Expand Down
23 changes: 7 additions & 16 deletions .github/workflows/chromatic-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Chromatic
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- main

permissions:
contents: read
Expand All @@ -19,39 +22,27 @@ jobs:
fetch-depth: 0

- name: Create initial Report
if: always()
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const script = require('./.github/scripts/chromatic-initial-comment.cjs');
await script({ github, context });

- name: Check if stories changed
id: check-stories
run: |
if git diff --name-only origin/main...HEAD | grep -E '\.(stories)\.(tsx|ts|jsx|js)$|^\.storybook/'; then
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
- name: Setup pnpm
if: steps.check-stories.outputs.has_changes == 'true'
uses: pnpm/action-setup@v4

- name: Setup Node.js
if: steps.check-stories.outputs.has_changes == 'true'
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'

- name: Install dependencies
if: steps.check-stories.outputs.has_changes == 'true'
run: pnpm install --frozen-lockfile

- name: Publish to Chromatic
id: chromatic
if: steps.check-stories.outputs.has_changes == 'true'
uses: chromaui/action@latest
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
Expand All @@ -61,10 +52,10 @@ jobs:
continue-on-error: true

- name: Create Storybook report
if: always()
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@v7
env:
HAS_CHANGES: ${{ steps.check-stories.outputs.has_changes }}
CHANGE_COUNT: ${{ steps.chromatic.outputs.changeCount }}
BUILD_STATUS: ${{ steps.chromatic.outcome }}
STORYBOOK_URL: ${{ steps.chromatic.outputs.storybookUrl }}
BUILD_URL: ${{ steps.chromatic.outputs.buildUrl }}
Expand All @@ -74,7 +65,7 @@ jobs:
await script({ github, context, core });

- name: Fail if build failed
if: steps.check-stories.outputs.has_changes == 'true' && steps.chromatic.outcome == 'failure'
if: steps.chromatic.outcome == 'failure'
run: |
echo "::error::Storybook build failed! Please check the logs."
exit 1