Skip to content

Chore: CI/CD 워크플로우 캐시 최적화 - #201

Merged
ssilver01 merged 1 commit into
developfrom
chore/optimize-cicd
Apr 24, 2026
Merged

Chore: CI/CD 워크플로우 캐시 최적화#201
ssilver01 merged 1 commit into
developfrom
chore/optimize-cicd

Conversation

@ssilver01

@ssilver01 ssilver01 commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

📝 PR 유형

  • 🚀 feature 기능 추가
  • 🐞 버그 발생
  • 🔨 리팩토링
  • 📋 문서작성
  • 🌍 빌드 설정 및 문제
  • ETC

✅ 작업 목록

문제점

여러 워크플로우에서 pnpm + Node.js 셋업 로직이 중복되고 있었고, ci.yml의 job들이 순차 실행되어 파이프라인 시간이 불필요하게 길었습니다. 또한 actionlint 검증 중 보안 취약점과 쉘 문법 이슈가 발견되어 함께 수정했습니다.


변경 내용

1. Composite Action 추출 — .github/actions/setup-node-pnpm/action.yml

워크플로우마다 반복되던 pnpm + Node.js 셋업을 composite action으로 추출했습니다.

# 기존 (각 워크플로우마다 4줄씩 중복)
- uses: pnpm/action-setup@v2
  with:
    version: 8
- uses: actions/setup-node@v4
  with:
    node-version: 20
    cache: 'pnpm'
 
# 변경 (2줄로 단축)
- uses: ./.github/actions/setup-node-pnpm

적용된 워크플로우: chromatic.yml, ci.yml, pr-preview.yml

2. ci.yml — 병렬 실행 구조로 개선

Before: check-types → lint → prettier → build  (순차)
 
After:  check-types ┐
                    ├→ build  (병렬 후 합류)
        lint        ┘
  • 중복 캐시 제거
  • --frozen-lockfile 플래그 추가로 lockfile 불일치 감지
  • check-typeslint를 병렬 실행 후 build로 합류

3. pr-preview.yml — 패키지 매니저 통일

  • npmpnpm으로 변경 (프로젝트 전반과 일관성 확보)
  • Composite action 적용
  • --frozen-lockfile 추가

4. 보안 및 쉘 문법 이슈 수정

pr-notification.yml — Script Injection 취약점 차단

${{ github.event.pull_request.title }}를 인라인 스크립트에 직접 주입하면, PR 제목에 악성 쉘 명령어가 들어갔을 때 그대로 실행될 위험이 있었습니다. env: 블록으로 전달하도록 변경해 환경변수로 처리로 수정했습니다.

# 수정 전 — 텍스트 치환 방식 (위험)
run: |
  PR_TITLE="${{ github.event.pull_request.title }}"
 
# 수정 후 — env 주입 방식 (안전)
env:
  PR_TITLE: ${{ github.event.pull_request.title }}
run: |
  # $PR_TITLE 그대로 사용

pr-preview.yml

$GITHUB_OUTPUT 경로에 공백이 있을 경우 쉘이 단어를 분리해 오동작할 가능성 배제

# 수정 전
echo "preview_url=..." >> $GITHUB_OUTPUT
 
# 수정 후
echo "preview_url=..." >> "$GITHUB_OUTPUT"

캐시 동작 참고

cache: 'pnpm' 설정은 Node.js나 pnpm CLI가 아닌 **~/.pnpm-store(전역 패키지 저장소)**를 pnpm-lock.yaml 해시 기준으로 캐시

항목 매번 실행 여부
Node.js 설치 ✅ (runner 내장, 빠름)
pnpm CLI 설치 ✅ (빠름)
~/.pnpm-store 패키지 ❌ 캐시 복원

병렬 job들은 각 runner에서 독립적으로 같은 캐시를 복원하므로, 패키지를 여러 번 다운로드하지 않습니다.


검증 방법

# 문법 검증
brew install actionlint
actionlint .github/workflows/*.yml

@ssilver01 ssilver01 self-assigned this Apr 21, 2026
@ssilver01 ssilver01 added the 🚀 Deploy 배포 관련 label Apr 21, 2026
@vercel

vercel Bot commented Apr 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nitrogen-front-web Ready Ready Preview, Comment Apr 21, 2026 7:51am

@coderabbitai

coderabbitai Bot commented Apr 21, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@ssilver01 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 30 minutes and 6 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 30 minutes and 6 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9ef39053-b9fe-4133-bb4d-bbed702f2aa3

📥 Commits

Reviewing files that changed from the base of the PR and between 5aaeb42 and 1290f8a.

📒 Files selected for processing (5)
  • .github/actions/setup-node-pnpm/action.yml
  • .github/workflows/chromatic.yml
  • .github/workflows/ci.yml
  • .github/workflows/pr-notification.yml
  • .github/workflows/pr-preview.yml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/optimize-cicd

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown

🎉 구현한 기능 Preview: https://nitrogen-front-pbrorj1s1-ssilver01s-projects.vercel.app

@hyun907 hyun907 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR 제목에 잘못된 페이로드가 그대로 실행될 수 있는 고전적 취약점이었는데 env: 주입으로 깔끔하게 해결했네요!! 그리고 CI 품질 체감 포인트들 잘 챙긴 것 같습니다 👍

@ssilver01
ssilver01 merged commit af80426 into develop Apr 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚀 Deploy 배포 관련

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants