diff --git a/.github/actions/setup-node-pnpm/action.yml b/.github/actions/setup-node-pnpm/action.yml new file mode 100644 index 00000000..b318725d --- /dev/null +++ b/.github/actions/setup-node-pnpm/action.yml @@ -0,0 +1,14 @@ +name: Setup Node.js and pnpm +description: Node.js와 pnpm을 설치하고 pnpm 캐시를 설정합니다 + +runs: + using: composite + steps: + - name: pnpm 설치 + uses: pnpm/action-setup@v4 + + - name: 노드 설치 + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: 'pnpm' diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index 3ed504c0..e66c2eda 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -17,14 +17,8 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Setup pnpm - uses: pnpm/action-setup@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - cache: 'pnpm' + - name: Node.js 및 pnpm 설치 + uses: ./.github/actions/setup-node-pnpm - name: Install dependencies run: pnpm install --frozen-lockfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 31e0c8d3..24419b16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,9 +3,9 @@ name: CI - 빌드 및 린트 테스트 on: [pull_request] jobs: - build-and-lint: + check-types: if: | - github.actor == 'hyun907' || + github.actor == 'hyun907' || github.actor == 'ssilver01' runs-on: ubuntu-latest @@ -14,36 +14,55 @@ jobs: - name: 코드 체크아웃 uses: actions/checkout@v4 - - name: pnpm 설치 - uses: pnpm/action-setup@v4 - - - name: 노드 설치 - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - cache: 'pnpm' - - - name: 의존성 캐시 - uses: actions/cache@v4 - with: - path: | - **/node_modules - ~/.pnpm-store - key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm- + - name: Node.js 및 pnpm 설치 + uses: ./.github/actions/setup-node-pnpm - name: 의존성 설치 - run: pnpm install + run: pnpm install --frozen-lockfile - name: 타입 체크 run: pnpm check-types + lint: + if: | + github.actor == 'hyun907' || + github.actor == 'ssilver01' + + runs-on: ubuntu-latest + + steps: + - name: 코드 체크아웃 + uses: actions/checkout@v4 + + - name: Node.js 및 pnpm 설치 + uses: ./.github/actions/setup-node-pnpm + + - name: 의존성 설치 + run: pnpm install --frozen-lockfile + - name: 린트 체크 run: pnpm lint - name: 코드 포맷 체크 run: pnpm prettier + build: + if: | + github.actor == 'hyun907' || + github.actor == 'ssilver01' + + needs: [check-types, lint] + runs-on: ubuntu-latest + + steps: + - name: 코드 체크아웃 + uses: actions/checkout@v4 + + - name: Node.js 및 pnpm 설치 + uses: ./.github/actions/setup-node-pnpm + + - name: 의존성 설치 + run: pnpm install --frozen-lockfile + - name: 빌드 실행 run: pnpm build diff --git a/.github/workflows/pr-notification.yml b/.github/workflows/pr-notification.yml index c059625e..31e11ba4 100644 --- a/.github/workflows/pr-notification.yml +++ b/.github/workflows/pr-notification.yml @@ -13,12 +13,18 @@ jobs: steps: - name: Send Slack Notification + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_TITLE: ${{ github.event.pull_request.title }} + PR_URL: ${{ github.event.pull_request.html_url }} + PR_AUTHOR: ${{ github.event.pull_request.user.login }} + EVENT_NAME: ${{ github.event_name }} + REVIEW_STATE: ${{ github.event.review.state }} + REVIEWER: ${{ github.event.review.user.login }} + REQUESTED_REVIEWER: ${{ github.event.requested_reviewer.login }} + REQUESTED_TEAM: ${{ github.event.requested_team.name }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} run: | - PR_NUMBER=${{ github.event.pull_request.number }} - PR_TITLE="${{ github.event.pull_request.title }}" - PR_URL="${{ github.event.pull_request.html_url }}" - PR_AUTHOR="${{ github.event.pull_request.user.login }}" - EVENT_NAME="${{ github.event_name }}" # GitHub 유저네임 -> Slack User ID 매핑 get_slack_user_id() { @@ -36,10 +42,8 @@ jobs: } if [ "$EVENT_NAME" == "pull_request_review" ]; then - REVIEW_STATE="${{ github.event.review.state }}" # approved일 때만 알림 if [ "$REVIEW_STATE" == "approved" ]; then - REVIEWER="${{ github.event.review.user.login }}" PR_AUTHOR_SLACK_ID=$(get_slack_user_id "$PR_AUTHOR") MESSAGE="✅ *PR 승인! 리뷰 확인하러 와주세요*\n\n<@${PR_AUTHOR_SLACK_ID}> *승인자:* ${REVIEWER}\n*제목:* ${PR_TITLE} (#${PR_NUMBER})\n*링크:* ${PR_URL}" else @@ -47,10 +51,8 @@ jobs: fi else # 리뷰 요청된 사람 정보 가져오기 - REQUESTED_REVIEWER="${{ github.event.requested_reviewer.login }}" if [ -z "$REQUESTED_REVIEWER" ]; then # 팀이 요청된 경우 - REQUESTED_TEAM="${{ github.event.requested_team.name }}" MESSAGE="👀 *리뷰 요청!*\n\n*요청 대상:* @${REQUESTED_TEAM} 팀\n*제목:* ${PR_TITLE} (#${PR_NUMBER})\n*작성자:* ${PR_AUTHOR}\n*링크:* ${PR_URL}" else SLACK_USER_ID=$(get_slack_user_id "$REQUESTED_REVIEWER") @@ -63,4 +65,4 @@ jobs: --data "{ \"text\": \"${MESSAGE}\" }" \ - ${{ secrets.SLACK_WEBHOOK_URL }} + "$SLACK_WEBHOOK" diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index aa84d14d..b274fd61 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -7,7 +7,7 @@ on: jobs: vercel-preview: if: | - github.actor == 'hyun907' || + github.actor == 'hyun907' || github.actor == 'ssilver01' runs-on: ubuntu-latest @@ -20,17 +20,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: pnpm 설치 - uses: pnpm/action-setup@v4 + - name: Node.js 및 pnpm 설치 + uses: ./.github/actions/setup-node-pnpm - - name: 노드 설치 - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - cache: 'pnpm' + - name: 의존성 설치 + run: pnpm install --frozen-lockfile - name: Vercel CLI 설치 - run: npm install --global vercel@latest + run: pnpm add -g vercel@latest - name: Vercel 환경변수 가져오기 run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} @@ -42,7 +39,7 @@ jobs: id: deploy run: | vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > vercel-output.txt - echo "preview_url=$(cat vercel-output.txt)" >> $GITHUB_OUTPUT + echo "preview_url=$(cat vercel-output.txt)" >> "$GITHUB_OUTPUT" - name: PR에 Preview URL 댓글 추가 uses: thollander/actions-comment-pull-request@v2