Skip to content

[Feat/#74] chore: github action Chromatic CD 개선#75

Open
seungdeok wants to merge 1 commit into
mainfrom
feat/#74
Open

[Feat/#74] chore: github action Chromatic CD 개선#75
seungdeok wants to merge 1 commit into
mainfrom
feat/#74

Conversation

@seungdeok
Copy link
Copy Markdown
Member

@seungdeok seungdeok commented Sep 19, 2025

📝 PR 설명

Chromatic CD가 pull_request에서만 comment를 추가하도록 workflow를 개선하였습니다.

관련된 이슈 넘버

close #74

✅ 작업 목록

  • workflow(.github/workflows/chromatic-CD.yml) 개선

📚 논의사항

📚 ETC

Summary by CodeRabbit

  • Chores
    • Chromatic CI에서 Storybook URL 댓글 게시 스텝의 실행 대상을 pull_request 이벤트로 제한했습니다.
    • workflow_dispatch 등 비-PR 트리거에서는 해당 스텝이 자동으로 건너뛰어집니다.
    • Chromatic 배포와 Slack 알림 흐름은 기존과 동일하게 유지됩니다.
    • 불필요한 댓글 발생이 줄어 PR 스레드 가독성과 신뢰도가 개선됩니다.
    • 제품 기능에는 변경이 없으며, 사용자 경험에는 영향이 없습니다.

@seungdeok seungdeok requested a review from widse September 19, 2025 14:16
@seungdeok seungdeok self-assigned this Sep 19, 2025
@seungdeok seungdeok added the enhancement New feature or request label Sep 19, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 19, 2025

📝 Walkthrough

Walkthrough

GitHub Actions 워크플로우 .github/workflows/chromatic-CD.yml에서 "Add Storybook URL Comment" 스텝에 조건을 추가하여 pull_request 이벤트에서만 실행되도록 변경되었습니다. 다른 스텝(Chromatic 배포, Slack 알림)은 변경되지 않았습니다.

Changes

Cohort / File(s) Summary
Chromatic CD 워크플로우 조건 추가
\.github/workflows/chromatic-CD.yml
"Add Storybook URL Comment" 스텝에 pull_request 이벤트 전용 조건을 추가하여 workflow_dispatch 등 비-PR 트리거에서 댓글 게시를 건너뜀. 나머지 스텝 로직/메시지는 변경 없음.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Dev as Developer
    participant GH as GitHub Actions
    participant Chrom as Chromatic
    participant Slack as Slack

    Dev->>GH: Trigger workflow (pull_request or workflow_dispatch)
    GH->>Chrom: Run Chromatic deployment
    Chrom-->>GH: Deployment result (URL)

    alt Event == pull_request
        GH->>GH: if: event_name == 'pull_request'
        GH->>GH: Add Storybook URL Comment (on PR)
    else Event != pull_request
        GH->>GH: Skip PR comment step
    end

    GH->>Slack: Send notification
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • widse

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed PR 제목 "[Feat/#74] chore: github action Chromatic CD 개선"은 변경의 핵심인 Chromatic CD 워크플로 개선을 명확히 나타내어 변경사항과 직접적으로 연관되어 있습니다; 다만 "Feat"와 "chore"가 동시에 표기되어 접두사가 중복되고 영어·한국어 혼용으로 다소 장황합니다.
Linked Issues Check ✅ Passed PR은 .github/workflows/chromatic-CD.yml에서 "Add Storybook URL Comment" 스텝에 pull_request 조건을 추가하여 workflow_dispatch로 수동 실행할 때 댓글을 시도하지 않도록 변경했으며, 이로써 이슈 #74에서 지적한 수동 트리거 시 댓글로 인한 실패를 방지하려는 주요 목표를 충족합니다; Chromatic 배포 및 Slack 알림 로직은 변경되지 않았습니다.
Out of Scope Changes Check ✅ Passed 변경이 워크플로 파일(.github/workflows/chromatic-CD.yml) 한 곳에 국한되어 있고 코드베이스의 다른 소스나 공개 API에 영향이 없으므로 범위 외 변경은 발견되지 않습니다.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/#74

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (6)
.github/workflows/chromatic-CD.yml (6)

61-79: Slack 성공 알림의 PR URL 참조는 비‑PR 이벤트에서 빈 값이 될 수 있음

workflow_dispatch에서도 이 스텝은 실행되지만 github.event.pull_request.html_url은 비어 있을 수 있습니다. 실패를 유발하진 않더라도 메시지 품질 저하가 있습니다. 아래 둘 중 한 가지로 정리 제안:

  • Option A: PR 이벤트에서만 전송
  • Option B: 비‑PR에선 Run URL/커밋 링크로 대체

예시 (Option B):

-      - name: Send Slack Success Notification
-        if: success()
+      - name: Send Slack Success Notification
+        if: success()
         uses: slackapi/slack-github-action@v1.26.0
         with:
           payload: |
             {
               "blocks": [
                 {
                   "type": "section",
                   "text": {
                     "type": "mrkdwn",
-                    "text": "✨ **Storybook 배포가 완료되었습니다!** \n\n🔍 PR: ${{ github.event.pull_request.html_url }}\n📚 Storybook: ${{ steps.chromatic.outputs.storybookUrl }}\n\n💬 피드백 부탁드립니다!"
+                    "text": "✨ **Storybook 배포가 완료되었습니다!** \n\n🔍 Context: ${{ github.event_name == 'pull_request' && github.event.pull_request.html_url || format('{0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id) }}\n📚 Storybook: ${{ steps.chromatic.outputs.storybookUrl }}\n\n💬 피드백 부탁드립니다!"
                   }
                 }
               ]
             }

수동 실행 시 Slack 메시지에 올바른 링크가 나오는지 확인 부탁드립니다.


81-99: Slack 실패 알림도 동일한 PR URL 빈 값 이슈 가능

성공 알림과 동일한 방식으로 가드/대체 링크 적용을 권장합니다. 최소 변경이라면 PR 이벤트로 한정:

-      - name: Send Slack Failure Notification
-        if: failure()
+      - name: Send Slack Failure Notification
+        if: failure() && github.event_name == 'pull_request'

46-49: Chromatic 액션 @latest는 재현성을 해칩니다 — 버전/SHA 고정 권장

빌드 환경 재현성과 공급망 안전을 위해 chromaui/action@<semver> 또는 커밋 SHA로 고정하세요. 동일하게 actions/checkout, actions/setup-node, pnpm/action-setup, slackapi/slack-github-action도 고정 권장.

Dependabot으로 GitHub Actions 업데이트 자동화도 고려해 주세요.


3-6: 권한 범위 최소화

워크플로우 전역 permissions 대신 잡 단위로 이동해 범위를 축소하는 것을 권장합니다. (이 워크플로우는 단일 잡이므로 동작은 동일하나, 향후 잡 추가 시 사고 범위를 줄일 수 있습니다.)


10-18: 트리거 타입 보강(선택)

PR이 다시 열리거나(draft → ready_for_review) 갱신될 때도 댓글/알림이 필요하면 typesreopened, ready_for_review 추가를 고려하세요.


19-23: 중복 실행 취소를 위한 concurrency 설정 제안(선택)

푸시가 연달아 들어오는 PR에서 이전 실행을 취소하면 Chromatic 사용량/알림 노이즈를 줄일 수 있습니다.

예시:

concurrency:
  group: chromatic-${{ github.ref }}
  cancel-in-progress: true
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4528a5a and 9d008b1.

📒 Files selected for processing (1)
  • .github/workflows/chromatic-CD.yml (1 hunks)
🔇 Additional comments (1)
.github/workflows/chromatic-CD.yml (1)

51-54: PR 이벤트에서만 PR 댓글 작성하도록 가드 추가 — 문제 재발 방지에 적합

workflow_dispatch에서 실패하던 코멘트 액션을 안전하게 건너뜁니다. 수동 트리거로 한 번 실행해 실제로 에러가 사라졌는지 확인만 부탁드립니다.


- name: Add Storybook URL Comment
if: ${{ github.event_name == 'pull_request' }}
uses: thollander/actions-comment-pull-request@v1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

🧩 Analysis chain

액션 버전 고정 및 최신 메이저 확인 권장

thollander/actions-comment-pull-request@v1은 오래되었을 수 있습니다. 공급망/재현성 측면에서 메이저 최신 또는 커밋 SHA로 고정을 권장합니다. 또한 comment-tag 옵션으로 “덮어쓰기(업데이트)”를 사용하면 코멘트 중복을 방지할 수 있습니다.

예시:

-        uses: thollander/actions-comment-pull-request@v1
+        uses: thollander/actions-comment-pull-request@v2
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         with:
           message: |
             📚 Storybook is ready for review!
             🔗 Preview: ${{ steps.chromatic.outputs.storybookUrl }}
+          comment-tag: chromatic-preview
+          allow-repeats: false

🌐 Web query:

thollander/actions-comment-pull-request의 최신 메이저 버전과 SHA 고정 가이드가 무엇인지?

💡 Result:

요약:

  • 최신 메이저 버전: v3 (최신 릴리스 v3.0.1 — 2024‑11‑02). [1][2]
  • SHA 고정 가이드: 보안상 액션은 전체 길이(commit SHA)로 고정(pin)해야 함 — workflow의 uses 필드에 커밋 SHA를 사용(예: uses: thollander/actions-comment-pull-request@)하고 원래 태그/버전은 주석으로 남기는 것을 권장. 자세한 권고와 예시는 GitHub 문서 참조. [3][1]

참고자료:

  1. thollander/actions-comment-pull-request README (사용 예시: thollander/actions-comment-pull-request@v3). [1]
  2. Releases (최신: v3.0.1, 태그 및 릴리스 노트). [2]
  3. GitHub 보안 권고 — 액션을 전체 길이 커밋 SHA로 고정할 것(권장 이유 및 예시). [3]

thollander/actions-comment-pull-request을 v3로 업데이트하고 커밋 SHA로 고정하세요

  • 파일: .github/workflows/chromatic-CD.yml (line 53) — 현재: uses: thollander/actions-comment-pull-request@v1. 최신 메이저는 v3 (최신 릴리스 v3.0.1 — 2024-11-02). 보안상 전체 커밋 SHA로 핀하는 것을 권장: uses: thollander/actions-comment-pull-request@ (태그/버전은 주석으로 보관).
  • 중복 코멘트 방지: with: 아래에 comment-tag: chromatic-preview 및 allow-repeats: false 추가.
🤖 Prompt for AI Agents
.github/workflows/chromatic-CD.yml around line 53: the action reference uses
thollander/actions-comment-pull-request@v1; update it to the v3 release and pin
to the exact commit SHA (replace the @v1 ref with @<full-commit-sha>) while
preserving the human-readable tag/version as a comment; additionally, under the
action's with: block add comment-tag: chromatic-preview and allow-repeats: false
to prevent duplicate comments.

Copy link
Copy Markdown
Member

@widse widse left a comment

Choose a reason for hiding this comment

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

@seungdeok
하나의 pr에서 ui 수정으로 인해 commit push로 ui 수정이 일어났을때 새로 갱신된 chromatic url 이 추가가 되어야할거 같은데 이렇게 변경해도 문제가 없는지 확인 필요할거 같아요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

♻️ [Refactor] chromatic CD workflow 개선

2 participants