Skip to content

Commit

Permalink
๐Ÿ”จ refactor: Github Actions ์›Œํฌํ”Œ๋กœ ๋ฆฌํŒฉํ† ๋ง (#218)
Browse files Browse the repository at this point in the history
* ๐Ÿ“ฆ chore: install action ์ž‘์„ฑ

* ๐Ÿ“ฆ chore: install action ์ ์šฉ

* ๐Ÿ“ฆ chore: vercel, chromatic ๋ฐฐํฌ ์ฃผ์†Œ ๊ฐ๊ฐ ์ฝ”๋ฉ˜ํŠธ ์ž‘์„ฑ

* ๐Ÿš‘ fix: ์˜์กด์„ฑ ์„ค์น˜ run ์ปค๋งจ๋“œ์— shell ์„ค์ • ์ถ”๊ฐ€

* ๐Ÿ“ฆ chore: react preview ๋ฐฐํฌ ํ…์ŠคํŠธ emoji ๋ณ€๊ฒฝ

* ๐Ÿ“ฆ chore: CI ๋‹จ๊ณ„์— ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ˆ˜ํ–‰ ์ถ”๊ฐ€

* ๐Ÿ“ฆ chore: vercel ๊ด€๋ จ env๋ฅผ job ์ชฝ์œผ๋กœ ์ด๋™

* ๐Ÿ“ฆ chore: CI ๋‹จ๊ณ„์— ๋ฆฐํŠธ ๊ฒ€์‚ฌ ์ถ”๊ฐ€

* โž– remove: CI ๋‹จ๊ณ„์—์„œ์˜ lint ๋‹ค์‹œ ์ œ๊ฑฐ
  • Loading branch information
bbearcookie authored Feb 26, 2024
1 parent ee64df1 commit 0f360aa
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 63 deletions.
22 changes: 22 additions & 0 deletions .github/actions/install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Install
description: 'Node.js์™€ NPM ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.'
runs:
using: composite
steps:
- 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: ์˜์กด์„ฑ ์„ค์น˜
shell: bash
if: steps.npm-cache.outputs.cache-hit != 'true'
run: npm ci
18 changes: 2 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,8 @@ jobs:
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: Node.js ๋ฐ NPM ์„ค์น˜
uses: ./.github/actions/install

- name: Chromatic์— ๋ฐฐํฌ
id: chromatic
Expand Down
84 changes: 37 additions & 47 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
name: Preview

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

on:
pull_request:
branches: ['main', feat/**, refactor/**, fix/**, chore/**]

jobs:
build:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
command: ['build', 'test']
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: Node.js ๋ฐ NPM ์„ค์น˜
uses: ./.github/actions/install

- name: React ๋นŒ๋“œ
run: npm run build --if-present
- run: npm run ${{ matrix.command }}

chromatic-preview:
runs-on: ubuntu-latest
Expand All @@ -43,21 +27,8 @@ jobs:
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: Node.js ๋ฐ NPM ์„ค์น˜
uses: ./.github/actions/install

- name: Chromatic์— ๋ฐฐํฌ
id: chromatic
Expand All @@ -67,11 +38,29 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
onlyChanged: true
autoAcceptChanges: true

- name: ํ˜„์žฌ ์‹œ๊ฐ„ ๊ฐ€์ ธ์˜ค๊ธฐ
uses: josStorer/get-current-time@v2
id: current-time
with:
format: YYYYMMDD-HH
utcOffset: '+09:00'

- name: PR ์ฝ”๋ฉ˜ํŠธ๋กœ Preview URL ๋‚จ๊ธฐ๊ธฐ
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: ${{github.event.number}}-chromatic
message: |
๐Ÿš€ Storybook Preview ๋ณด๋Ÿฌ๊ฐ€๊ธฐ: ${{ steps.chromatic.outputs.storybookUrl }}
โฐ ๋ฐฐํฌ ์ผ์‹œ: ${{ steps.current-time.outputs.readableTime }}
outputs:
storybook_url: ${{ steps.chromatic.outputs.storybookUrl }}

vercel-preview:
runs-on: ubuntu-latest
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- uses: actions/checkout@v4

Expand All @@ -89,17 +78,18 @@ jobs:
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: ํ˜„์žฌ ์‹œ๊ฐ„ ๊ฐ€์ ธ์˜ค๊ธฐ
uses: josStorer/get-current-time@v2
id: current-time
with:
format: YYYYMMDD-HH
utcOffset: '+09:00'

- name: PR ์ฝ”๋ฉ˜ํŠธ๋กœ Preview URL ๋‚จ๊ธฐ๊ธฐ
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: ${{github.event.number}}
comment_tag: ${{github.event.number}}-vercel
message: |
๐Ÿš€ Storybook Preview ๋ณด๋Ÿฌ๊ฐ€๊ธฐ: ${{ needs.chromatic-preview.outputs.storybook_url }}
๐Ÿš€ React Preview ๋ณด๋Ÿฌ๊ฐ€๊ธฐ: ${{ needs.vercel-preview.outputs.vercel_url }}
๐ŸŽฎ React Preview ๋ณด๋Ÿฌ๊ฐ€๊ธฐ: ${{ steps.deploy.outputs.preview_url }}
โฐ ๋ฐฐํฌ ์ผ์‹œ: ${{ steps.current-time.outputs.readableTime }}

0 comments on commit 0f360aa

Please sign in to comment.