Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Chromatic을 사용한 storybook 배포 및 GitHub Actions을 통한 자동 배포 #22

Merged
merged 6 commits into from
Jul 13, 2024
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
53 changes: 53 additions & 0 deletions .github/workflows/deploy-storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: 'Deploy Storybook with Chromatic'

on:
pull_request:
branches: [main]
paths:
- '**.stories.tsx'
push:
branches: [main]
paths:
- '**.stories.tsx'

jobs:
deployment:
runs-on: ubuntu-latest
steps:
- uses: pnpm/action-setup@v4
with:
version: 8

- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}-storybook
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pnpm install

- name: Publish to chromatic
id: chromatic
uses: chromaui/action@v1
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
buildScriptName: build-storybook
onlyChanged: true

- name: comment PR
uses: thollander/actions-comment-pull-request@v1
if: ${{ github.event_name == 'pull_request' }}
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
with:
message: '🚀storybook: ${{ steps.chromatic.outputs.storybookUrl }}'
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ next-env.d.ts

## Panda
styled-system
styled-system-studio
styled-system-studio
*storybook.log
17 changes: 17 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { StorybookConfig } from '@storybook/nextjs';

const config: StorybookConfig = {
stories: ['../**/*.mdx', '../**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
'@storybook/addon-onboarding',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@chromatic-com/storybook',
'@storybook/addon-interactions',
],
framework: {
name: '@storybook/nextjs',
options: {},
},
};
export default config;
14 changes: 14 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Preview } from '@storybook/react';

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
24 changes: 24 additions & 0 deletions components/atoms/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { Meta, StoryObj } from '@storybook/react';

import { Button } from './Button';

const meta: Meta<typeof Button> = {
title: 'components/atoms/button',
component: Button,
argTypes: {
disabled: {
control: 'boolean',
},
onClick: { action: 'clicked' },
},
};

export default meta;

type Story = StoryObj<typeof Button>;

export const Basic: Story = {
args: {
children: 'Button',
},
};
9 changes: 9 additions & 0 deletions components/atoms/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ButtonHTMLAttributes, forwardRef } from 'react';

interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {}

export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
({ ...props }, ref) => <button ref={ref} {...props} />,
);

Button.displayName = 'Button';
1 change: 1 addition & 0 deletions components/atoms/Button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Button } from './Button';
1 change: 1 addition & 0 deletions components/atoms/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Button } from './Button';
18 changes: 16 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"start": "next start",
"lint": "next lint",
"format:fix": "prettier --write --ignore-path .gitignore .",
"postinstall": "husky install"
"postinstall": "husky install",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"dependencies": {
"@tanstack/react-query": "^5.45.1",
Expand All @@ -19,22 +21,34 @@
"react-dom": "^18"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.6.1",
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@pandacss/dev": "^0.41.0",
"@storybook/addon-essentials": "^8.2.1",
"@storybook/addon-interactions": "^8.2.1",
"@storybook/addon-links": "^8.2.1",
"@storybook/addon-onboarding": "^8.2.1",
"@storybook/blocks": "^8.2.1",
"@storybook/nextjs": "^8.2.1",
"@storybook/react": "^8.2.1",
"@storybook/test": "^8.2.1",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"eslint": "^8",
"chromatic": "^11.5.5",
"eslint": "^8.57.0",
"eslint-config-next": "14.2.4",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-simple-import-sort": "^12.1.0",
"eslint-plugin-storybook": "^0.8.0",
"husky": "^8.0.3",
"lint-staged": "^15.2.7",
"prettier": "^3.3.2",
"storybook": "^8.2.1",
"typescript": "^5"
},
"lint-staged": {
Expand Down
Loading
Loading