Skip to content

Commit

Permalink
๐Ÿ“ฆ chore: Chromatic ์„ค์น˜ ๋ฐ CI/CD ์›Œํฌํ”Œ๋กœ ์ž‘์„ฑ (#7)
Browse files Browse the repository at this point in the history
* ๐Ÿ“ฆ chore: Chromatic ์„ค์น˜

* ๐Ÿ“ฆ chore: PR์‹œ Chromatic ๋ฐฐํฌ CI ์ž‘์„ฑ

* ๐Ÿ“ฆ chore: main์— push์‹œ Chromatic ๋ฐฐํฌ CI ์›Œํฌํ”Œ๋กœ ์ž‘์„ฑ

* ๐Ÿš‘ fix: ์˜์กด์„ฑ ์บ์‹ฑ path ์ˆ˜์ •

* ๐Ÿ“ฆ chore: ๋นŒ๋“œ ํ…Œ์ŠคํŠธ job ์ด๋ฆ„ build๋กœ ๋ณ€๊ฒฝ

* ๐Ÿ“ฆ chore: Vercel ๋ฐฐํฌ CI/CD ์„ธํŒ… (#10)

* ๐Ÿ“ฆ chore: Pull Request์‹œ Preview์— Vercel ์ถ”๊ฐ€

* ๐Ÿ“ฆ chore: ์ž„์‹œ๋กœ preview ๋Œ€์ƒ ๋ธŒ๋žœ์น˜ ๋ณ€๊ฒฝ

* ๐Ÿ“ฆ chore: preview ๋Œ€์ƒ ๋ธŒ๋žœ์น˜ main์œผ๋กœ ์›์ƒ๋ณต๊ตฌ

* ๐Ÿ“ฆ chore: main ๋ธŒ๋žœ์น˜ vercel deploy ์›Œํฌํ”Œ๋กœ ์ž‘์„ฑ

* โœ… test: ์ž„์‹œ๋กœ deploy ๋Œ€์ƒ ๋ธŒ๋žœ์น˜ ๋ณ€๊ฒฝ

* ๐Ÿ“ฆ chore: deploy ๋Œ€์ƒ ๋ธŒ๋žœ์น˜ main์œผ๋กœ ์›์ƒ๋ณต๊ตฌ

* ๐Ÿš€ deploy: Vercel ๋ฐฐํฌ ํŒ€์œผ๋กœ ๋ณ€๊ฒฝ

* โœ… test: preview ๋Œ€์ƒ ์ž„์‹œ ๋ณ€๊ฒฝ

* โœ… test: sleep 60์ดˆ๋กœ ๋ณ€๊ฒฝ (ํ…Œ์ŠคํŠธ)

* โœ… test: sleep 30์ดˆ๋กœ ์›์ƒ๋ณต๊ตฌ

* ๐Ÿ“ฆ chore: Vercel SPA Fallback ์„ค์ •

* ๐Ÿ“ฆ chore: preview ๋Œ€์ƒ ๋ธŒ๋žœ์น˜ main์œผ๋กœ ์›์ƒ๋ณต๊ตฌ

* ๐Ÿš€ deploy: ๋ฐฐํฌ

* โœ… test: output ์ถœ๋ ฅ ํ…Œ์ŠคํŠธ

* โœ… test: vercel-output.txt ์ƒ์„ฑ ํ›„ ์ถœ๋ ฅ

* โœ… test: $GITHUB_OUTPUT ์œผ๋กœ ์ง์ ‘ URL ๋‚ด๋ณด๋‚ด๊ธฐ

* โœ… test: cat vercel-output.txt >> $GITHUB_OUTPUT

* โœ… test: env.VERCEL_URL ๋กœ ์‹œ๋„

* โœ… test: $GITHUB_OUTPUT ๋กœ ๋ณ€๊ฒฝ

* ๐Ÿ“ style: ์›Œํฌํ”Œ๋กœ ์ฝ”๋“œ ์ •๋ฆฌ
  • Loading branch information
bbearcookie authored Jan 17, 2024
1 parent e9c35ad commit 01401e0
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 34 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Deploy

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

on:
push:
branches: ['main']

jobs:
chromatic:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Node.js ์„ค์น˜
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'

- name: ์˜์กด์„ฑ ์บ์‹ฑ
uses: actions/cache@v3
id: npm-cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

- name: ์˜์กด์„ฑ ์„ค์น˜
if: steps.npm-cache.outputs.cache-hit != 'true'
run: npm ci

- name: Chromatic์— ๋ฐฐํฌ
id: chromatic
uses: chromaui/action@latest
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
onlyChanged: true
autoAcceptChanges: true

vercel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Vercel CLI ์„ค์น˜
run: npm install --global vercel@latest

- name: Vercel ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ๊ฐ€์ ธ์˜ค๊ธฐ
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}

- name: Project Artifacts ๋นŒ๋“œํ•˜๊ธฐ
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}

- name: Vercel์— Project Artifacts ๋ฐฐํฌํ•˜๊ธฐ
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
104 changes: 104 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Preview

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

on:
pull_request:
branches: ['main']

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Node.js ์„ค์น˜
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'

- name: ์˜์กด์„ฑ ์บ์‹ฑ
uses: actions/cache@v3
id: npm-cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

- name: ์˜์กด์„ฑ ์„ค์น˜
if: steps.npm-cache.outputs.cache-hit != 'true'
run: npm ci

- name: React ๋นŒ๋“œ
run: npm run build --if-present

chromatic-preview:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Node.js ์„ค์น˜
uses: actions/setup-node@v4
with:
node-version: 20

- name: ์˜์กด์„ฑ ์บ์‹ฑ
uses: actions/cache@v3
id: npm-cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

- name: ์˜์กด์„ฑ ์„ค์น˜
if: steps.npm-cache.outputs.cache-hit != 'true'
run: npm ci

- name: Chromatic์— ๋ฐฐํฌ
id: chromatic
uses: chromaui/action@latest
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
onlyChanged: true
autoAcceptChanges: true
outputs:
storybook_url: ${{ steps.chromatic.outputs.storybookUrl }}

vercel-preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Vercel CLI ์„ค์น˜
run: npm install --global vercel@latest

- name: Vercel ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ๊ฐ€์ ธ์˜ค๊ธฐ
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}

- name: Project Artifacts ๋นŒ๋“œํ•˜๊ธฐ
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}

- name: Vercel์— Project Artifacts ๋ฐฐํฌํ•˜๊ธฐ
id: deploy
run: |
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > vercel-output.txt
echo "preview_url=$(cat vercel-output.txt)" >> $GITHUB_OUTPUT
outputs:
vercel_url: ${{ steps.deploy.outputs.preview_url }}

github-bot:
runs-on: ubuntu-latest
needs: [chromatic-preview, vercel-preview]
steps:
- name: PR ์ฝ”๋ฉ˜ํŠธ๋กœ Preview URL ๋‚จ๊ธฐ๊ธฐ
uses: thollander/actions-comment-pull-request@v2
with:
message: |
๐Ÿš€ Storybook Preview ๋ณด๋Ÿฌ๊ฐ€๊ธฐ: ${{ needs.chromatic-preview.outputs.storybook_url }}
๐Ÿš€ React Preview ๋ณด๋Ÿฌ๊ฐ€๊ธฐ: ${{ needs.vercel-preview.outputs.vercel_url }}
31 changes: 0 additions & 31 deletions .github/workflows/pull_request.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ dist-ssr
*.njsproj
*.sln
*.sw?

.vercel
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@commitlint/cli": "^18.4.4",
"@commitlint/config-conventional": "^18.4.4",
"@storybook/addon-essentials": "^7.6.8",
"@storybook/addon-interactions": "^7.6.8",
"@storybook/addon-links": "^7.6.8",
"@storybook/blocks": "^7.6.8",
"@storybook/react": "^7.6.8",
"@storybook/react-vite": "^7.6.8",
"@storybook/test": "^7.6.8",
"@commitlint/cli": "^18.4.4",
"@commitlint/config-conventional": "^18.4.4",
"@tanstack/eslint-plugin-query": "^5.17.7",
"@tanstack/react-query-devtools": "^5.17.12",
"@types/node": "^20.11.2",
Expand All @@ -46,6 +46,7 @@
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-react": "^4.2.1",
"chromatic": "^10.3.0",
"commitlint-config-git-commit-emoji": "^1.0.0",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
3 changes: 2 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { ROUTER_PATHS } from './constants/routerPaths';
const App = () => {
return (
<>
<h1>Hello World</h1>
<h1>Hello World!</h1>
<p>Vercel ๋ฐฐํฌ!</p>
<EmotionTestButton size="small">์ด๋ชจ์…˜ ํ…Œ์ŠคํŠธ</EmotionTestButton>
<Link to={ROUTER_PATHS.TEST_CONSTANT}>Test Constant Page</Link>
<Link to={ROUTER_PATHS.TEST_VARIABLE('5')}>Test 5 Page</Link>
Expand Down
6 changes: 6 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"routes": [
{ "handle": "filesystem" },
{ "src": "/(.*)", "dest": "/index.html" }
]
}

0 comments on commit 01401e0

Please sign in to comment.