Yejiin21의 스토리북 배포 및 NPM 배포 #46
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Storybook Deployment and Npm Publish | |
run-name: ${{ github.actor }}의 스토리북 배포 및 NPM 배포 | |
on: | |
pull_request: | |
branches: | |
- develop | |
jobs: | |
storybook: | |
runs-on: ubuntu-20.04 | |
outputs: | |
status: ${{ job.status }} | |
steps: | |
# 1️⃣ 코드 체크아웃 | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
# 2️⃣ Node.js 20.x 버전 설치 | |
- name: Use Node.js 20.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20.x' | |
# 3️⃣ 패키지 설치 | |
- run: yarn | |
# 4️⃣ Chromatic에 스토리북 배포 | |
- uses: chromaui/action@v1 | |
id: chromatic | |
with: | |
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# 5️⃣ NPM 인증 설정 | |
- run: | | |
npm config set '//registry.npmjs.org/:_authToken' ${{ secrets.NPM_TOKEN }} | |
npm config set access public | |
# 6️⃣ package.json의 homepage를 Chromatic 링크로 임시 변경 | |
- run: | | |
sed -i "s|CHROMATIC_HOMEPAGE|${{ steps.chromatic.outputs.storybookUrl }}|" package.json | |
# 7️⃣ NPM 패키지 배포 | |
- run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
# 8️⃣ homepage 복원 | |
- run: | | |
sed -i "s|${{ steps.chromatic.outputs.storybookUrl }}|CHROMATIC_HOMEPAGE|" package.json | |
# 9️⃣ 빌드 결과물(dist) 복사 | |
- run: cp -R build/* $GITHUB_WORKSPACE/dist/ |