-
Notifications
You must be signed in to change notification settings - Fork 1
Setting(project): auto reviewer/assignee/label workflow 작성 #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughPR에 브랜치 접두사 기반 자동 라벨링 워크플로(.github/workflows/label.yml)와 PR 오픈/리뷰 준비 시 자동 담당자·리뷰어 지정 워크플로(.github/workflows/review-assign.yml)를 추가했습니다. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as 개발자
participant GH as GitHub
participant WF as Workflow: label.yml
participant API as GitHub API
Dev->>GH: Pull Request 오픈 (브랜치 포함)
GH-->>WF: trigger pull_request.opened
WF->>WF: 브랜치 ref에서 접두사 추출
WF->>WF: 접두사 -> 라벨 매핑 조회
alt 라벨 일치
WF->>API: issues.addLabels(pr_number, [label])
API-->>WF: 200 OK
else 불일치
WF->>WF: "no matching label" 로그
end
sequenceDiagram
autonumber
actor Dev as 개발자
participant GH as GitHub
participant WF2 as Workflow: review-assign.yml
participant Act as Action hkusu/review-assign
Dev->>GH: PR 오픈 / ready_for_review
GH-->>WF2: trigger opened / ready_for_review
WF2->>Act: inputs: assignees=${{ github.event.pull_request.user.login }}, reviewers=${{ vars.REVIEWERS }}
Act-->>GH: Assignee 설정 및 리뷰어 요청
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (5)
.github/workflows/review-assign.yml (2)
15-15: 서플라이 체인 보안: 액션 버전을 커밋 SHA로 핀 고정하는 것을 고려해주세요
hkusu/review-assign-action@v1는 메이저 태그 고정만 되어 있습니다. 가능한 경우 커밋 SHA로 핀 고정하는 것이 권장됩니다.
3-6: Fork에서 온 PR 처리 전략 확인fork 기반 PR에서는
pull_request이벤트로는 쓰기 권한 토큰이 제한되어 reviewer/assignee 지정이 실패할 수 있습니다. 외부 기여를 받는 레포라면pull_request_target로의 전환 여부와 보안 트레이드오프를 검토해 주세요..github/workflows/label.yml (3)
3-6: 트리거 범위 확장 제안: reopened/synchronize/ready_for_review 포함 고려PR이 다시 열리거나 브랜치가 푸시로 업데이트되는 경우에도 라벨 부여가 필요하다면, 트리거 타입을 확장하세요.
on: pull_request: - types: [opened] + types: [opened, reopened, synchronize, ready_for_review]
31-33: 브랜치 프리픽스에 공백/느낌표 사용은 매칭되지 않을 가능성이 큽니다
'!HOTFIX','!BREAKING CHANGE'는 일반적인 브랜치 작명 규칙과 맞지 않습니다(공백 포함). 실제로는hotfix/…,breaking-change/…같은 형태가 더 흔합니다. 현재 구현은'/'앞의 첫 토큰만 비교하므로, 운영 규칙에 맞춰 키를 조정하는 것을 권장합니다.
15-16: actions/github-script 버전 최신화/핀 고정 검토가능하다면 최신 메이저 버전 사용 또는 커밋 SHA로 핀 고정을 권장합니다. 공급망 보안을 위해 모범 사례입니다.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
.github/workflows/label.yml(1 hunks).github/workflows/review-assign.yml(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: constantly-dev
PR: Pinback-Team/pinback-client#2
File: pnpm-workspace.yaml:3-3
Timestamp: 2025-08-18T13:48:59.021Z
Learning: constantly-dev는 docs 디렉터리를 컨벤션 문서 추가용으로 사용할 예정이라고 명시했습니다.
🪛 actionlint (1.7.7)
.github/workflows/label.yml
19-19: could not parse as YAML: yaml: line 19: mapping values are not allowed in this context
(syntax-check)
🪛 YAMLlint (1.37.1)
.github/workflows/label.yml
[error] 17-17: trailing spaces
(trailing-spaces)
[error] 53-53: no new line character at the end of file
(new-line-at-end-of-file)
[error] 19-19: syntax error: mapping values are not allowed here
(syntax)
🔇 Additional comments (1)
.github/workflows/review-assign.yml (1)
15-18: reviewer 대입값 포맷(쉼표/개행 구분)과 vars.REVIEWERS 존재 여부 확인 필요
hkusu/review-assign-action@v1는 reviewers 입력값 포맷(콤마/개행 구분)에 민감할 수 있습니다.${{ vars.REVIEWERS }}가 액션이 기대하는 형식으로 저장돼 있는지, 레포/오가니제이션 변수에 실제로 정의돼 있는지 점검이 필요합니다.확인 포인트:
- vars.REVIEWERS가 정의돼 있는가?
- 값 포맷이 액션 요구사항과 일치하는가? (예:
alice,bob혹은 줄바꿈 구분)필요시 포맷 보정을 위해 다음과 같이 명시적으로 작성할 수도 있습니다:
- reviewers: ${{ vars.REVIEWERS }} + reviewers: ${{ vars.REVIEWERS }} # 예: "alice,bob"
jllee000
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확인했씁니다! 간단한 질문 정도만 확인해주시면 감사하겠습니당
머지 이후 액션 잘 돌아가는 지 확인해볼게요!
| - uses: hkusu/review-assign-action@v1 | ||
| with: | ||
| assignees: ${{ github.event.pull_request.user.login }} | ||
| reviewers: ${{ vars.REVIEWERS }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just 궁금증! vars.Reviewers등은 어디에 선언되어 있을까여?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vars.REVIEWERS는 저희 레포 setting에 들어가면 Variable 설정할 수 있는데 거기서 REVIEWERS 이름으로 작성해두었습니다 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (2)
.github/workflows/label.yml (2)
7-10: 권한 설정 적절: labels 추가를 위한 issues: write 포함 확인됨이전 리뷰 피드백대로
issues: write가 추가되어 레이블 추가 시 권한 오류가 나지 않겠습니다. 좋습니다.
18-19: YAML 스크립트 블록 구문 수정 완료
script: |형태로 멀티라인 지정이 올바르게 적용되어 actionlint/YAMLlint 오류 원인이 해소되었습니다. 잘 반영되었습니다.
🧹 Nitpick comments (3)
.github/workflows/label.yml (3)
39-40: 브랜치 접두사 소문자 변환으로 매칭 안정화대소문자 섞인 브랜치(
Feat/...,HOTFIX/...)에서도 매핑되도록 소문자 변환을 권장합니다.- const branchPrefix = branchName.split('/')[0]; - console.log(`Branch prefix is: ${branchPrefix}`); + const branchPrefix = branchName.split('/')[0].toLowerCase(); + console.log(`Branch prefix is: ${branchPrefix}`);
3-6: 트리거 범위 확장 제안: ready_for_review, reopened (또는 pull_request_target)
- 드래프트 -> 리뷰 준비 전환 시점에도 라벨을 붙이려면
ready_for_review를 추가하세요.- PR 재오픈 시 라벨이 없는 경우를 커버하려면
reopened도 고려할 수 있습니다.- 외부 포크 PR에도 라벨을 붙여야 한다면
pull_request_target로의 전환을 검토하세요(이 워크플로우는 체크아웃 없이 이벤트 페이로드만 사용하므로 비교적 안전). 보안상 PR 코드 체크아웃/실행은 금지.on: - pull_request: - types: [opened] + pull_request: + types: [opened, ready_for_review, reopened]
46-51: 문맥 명시성: issue_number는 PR 번호를 직접 참조하는 편이 명확현 코드도 동작하나, 이벤트 페이로드에서 PR 번호를 직접 사용하는 것이 가독성/명시성에 더 좋습니다.
- issue_number: context.issue.number, + issue_number: context.payload.pull_request.number,
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
.github/workflows/label.yml(1 hunks).github/workflows/review-assign.yml(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/review-assign.yml
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: constantly-dev
PR: Pinback-Team/pinback-client#2
File: pnpm-workspace.yaml:3-3
Timestamp: 2025-08-18T13:48:59.021Z
Learning: constantly-dev는 docs 디렉터리를 컨벤션 문서 추가용으로 사용할 예정이라고 명시했습니다.
🪛 actionlint (1.7.7)
.github/workflows/label.yml
16-16: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
| const labelMapping = { | ||
| 'setting': 'setting', | ||
| 'feat': 'feat', | ||
| 'fix': 'fix', | ||
| 'api': 'api', | ||
| 'refactor': 'refactor', | ||
| 'chore': 'chore', | ||
| 'deploy': 'deploy', | ||
| 'comment': 'comment', | ||
| 'test': 'test', | ||
| 'rename': 'rename', | ||
| 'remove': 'remove', | ||
| 'docs': 'docs', | ||
| '!HOTFIX': '!HOTFIX', | ||
| '!BREAKING CHANGE': '!BREAKING CHANGE' | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
브랜치 접두사 키에서 공백/특수문자 사용은 매칭 불가 가능성 큼
'!HOTFIX', '!BREAKING CHANGE'는 실제 브랜치 접두사로 쓰기 어렵습니다(공백 포함 및 ! 시작). 현재 로직에서는 매칭이 안 되어 의도한 라벨이 붙지 않을 확률이 높습니다. 일반적인 네이밍(hotfix, breaking-change)으로 매핑 키를 변경하는 것을 권장합니다.
- '!HOTFIX': '!HOTFIX',
- '!BREAKING CHANGE': '!BREAKING CHANGE'
+ 'hotfix': '!HOTFIX',
+ 'breaking-change': '!BREAKING CHANGE',
+ 'breaking': '!BREAKING CHANGE'참고: 아래 댓글의 소문자 변환과 함께 적용하면 대소문자 섞인 브랜치에도 잘 동작합니다.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const labelMapping = { | |
| 'setting': 'setting', | |
| 'feat': 'feat', | |
| 'fix': 'fix', | |
| 'api': 'api', | |
| 'refactor': 'refactor', | |
| 'chore': 'chore', | |
| 'deploy': 'deploy', | |
| 'comment': 'comment', | |
| 'test': 'test', | |
| 'rename': 'rename', | |
| 'remove': 'remove', | |
| 'docs': 'docs', | |
| '!HOTFIX': '!HOTFIX', | |
| '!BREAKING CHANGE': '!BREAKING CHANGE' | |
| }; | |
| const labelMapping = { | |
| 'setting': 'setting', | |
| 'feat': 'feat', | |
| 'fix': 'fix', | |
| 'api': 'api', | |
| 'refactor': 'refactor', | |
| 'chore': 'chore', | |
| 'deploy': 'deploy', | |
| 'comment': 'comment', | |
| 'test': 'test', | |
| 'rename': 'rename', | |
| 'remove': 'remove', | |
| 'docs': 'docs', | |
| 'hotfix': '!HOTFIX', | |
| 'breaking-change': '!BREAKING CHANGE', | |
| 'breaking': '!BREAKING CHANGE' | |
| }; |
🤖 Prompt for AI Agents
.github/workflows/label.yml around lines 19 to 34: the label mapping uses
branch-prefix keys like '!HOTFIX' and '!BREAKING CHANGE' which include special
chars and spaces and will fail to match real branches; change the mapping keys
to conventional, matchable names such as 'hotfix' and 'breaking-change' (or
similar hyphenated lowercase forms) and ensure the branch prefix is normalized
to lowercase (and trim/replace spaces) before lookup so mixed-case or spaced
prefixes match the mapping.
👍 혹시나 확인해보고 문제 생기면 다시 이슈파고 수정해보겠습니다~~ |
There was a problem hiding this 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 (5)
.github/workflows/label.yml (5)
3-6: 트리거 보강 제안: reopened 및 수동 실행 지원PR 재오픈 시 라벨 재적용이 필요할 수 있고, 수동 재실행이 유용합니다. 아래처럼 보강을 권장합니다.
on: pull_request: - types: [opened] + types: [opened, reopened] + workflow_dispatch:추가로, 포크에서 올라오는 PR도 라벨링하고 싶다면
pull_request_target로 전환을 고려하세요. 이 워크플로는 리포지토리 내 JS만 실행하므로 보안상 안전한 편입니다.-on: - pull_request: - types: [opened, reopened] +on: + pull_request_target: + types: [opened, reopened] + workflow_dispatch:
34-38: 브랜치 접두사 정규화(toLowerCase/trim)로 매칭 안정화네이밍 컨벤션이 깨진 경우(대문자/공백 포함)에도 라벨링이 동작하도록 접두사를 정규화하세요.
- const branchName = context.payload.pull_request.head.ref; + const branchName = context.payload.pull_request.head.ref ?? ''; console.log(`Branch name is: ${branchName}`); - const branchPrefix = branchName.split('/')[0]; + const branchPrefix = (branchName.split('/')[0] ?? '').trim().toLowerCase(); console.log(`Branch prefix is: ${branchPrefix}`);
19-33: 매핑 단순화: 동일 매핑은 Set 기반 허용 리스트로 축소 가능현재는 key와 value가 동일합니다. 유지보수성을 위해 허용 접두사 Set만 두고 라벨은 접두사 자체를 쓰는 편이 간결합니다.
- const labelMapping = { - 'setting': 'setting', - 'feat': 'feat', - 'fix': 'fix', - 'api': 'api', - 'refactor': 'refactor', - 'chore': 'chore', - 'deploy': 'deploy', - 'comment': 'comment', - 'test': 'test', - 'rename': 'rename', - 'remove': 'remove', - 'docs': 'docs', - }; + const allowedPrefixes = new Set([ + 'setting', + 'feat', + 'fix', + 'api', + 'refactor', + 'chore', + 'deploy', + 'comment', + 'test', + 'rename', + 'remove', + 'docs', + ]);
40-41: 위 단순화 적용 시 라벨 결정 로직 업데이트Set 기반으로 전환 시 아래처럼 치환하세요.
- const labelToAdd = labelMapping[branchPrefix]; + const labelToAdd = allowedPrefixes.has(branchPrefix) ? branchPrefix : undefined;
1-53: 컨벤션 문서화 제안: docs/에 브랜치 접두사 ↔ 라벨 매핑 명시팀 합의와 확장을 위해 docs 디렉터리에 간단한 표준 문서(브랜치 네이밍 규칙, 대응 라벨 목록, 예시)를 추가하면 좋습니다.
retrieved learnings를 근거로 보면, docs 디렉터리를 컨벤션 문서 용도로 쓸 계획이라고 하셨습니다. 필요하시면 초안(md) 생성해 드릴게요. 원하시는 항목을 알려주세요.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.github/workflows/label.yml(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: constantly-dev
PR: Pinback-Team/pinback-client#2
File: pnpm-workspace.yaml:3-3
Timestamp: 2025-08-18T13:48:59.021Z
Learning: constantly-dev는 docs 디렉터리를 컨벤션 문서 추가용으로 사용할 예정이라고 명시했습니다.
🔇 Additional comments (2)
.github/workflows/label.yml (2)
7-10: 권한 설정 적절합니다labels 추가를 위해
issues: write를 명시했고, PR 컨텍스트에 안전합니다.
16-16: actions/github-script v7 사용 확인Node16 EOL 이슈 회피에 적절한 선택입니다.
| if (labelToAdd) { | ||
| console.log(`Found matching label: ${labelToAdd}`); | ||
| await github.rest.issues.addLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| labels: [labelToAdd] | ||
| }); | ||
| } else { | ||
| console.log('No matching label found for the branch prefix.'); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
라벨 존재 여부 점검 권장 및 포크 PR 권한 주의
- 라벨이 리포지토리에 미리 생성되어 있는지 확인하세요. 없는 경우 API가 실패할 수 있습니다(리포 설정에 따라 다름).
- 포크에서 생성된 PR의
pull_request이벤트는 토큰이 read-only일 수 있어 라벨 추가가 실패합니다. 위 코멘트의pull_request_target전환을 검토하세요.
다음 스크립트로 현재 리포의 라벨 목록과 매핑에 필요한 라벨의 존재 여부를 빠르게 점검할 수 있습니다.
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) owner/repo 추출
origin_url="$(git config --get remote.origin.url)"
if [[ "$origin_url" =~ github.com[:/]+([^/]+/[^/.]+)(\.git)?$ ]]; then
repo="${BASH_REMATCH[1]}"
else
echo "Failed to parse owner/repo from: $origin_url" >&2
exit 1
fi
# 2) 기대 라벨 목록(매핑 기반)
expected=(setting feat fix api refactor chore deploy comment test rename remove docs)
# 3) 현재 라벨 조회
labels_json="$(curl -s "https://api.github.com/repos/${repo}/labels?per_page=100")"
have=($(printf "%s" "$labels_json" | jq -r '.[].name' | sort -u))
# 4) 누락 항목 출력
missing=()
for e in "${expected[@]}"; do
if ! printf "%s\n" "${have[@]}" | grep -qx "$e"; then
missing+=("$e")
fi
done
echo "Repo: $repo"
echo "Existing labels (${#have[@]}): ${have[*]}"
if ((${#missing[@]})); then
echo "Missing labels (${#missing[@]}): ${missing[*]}"
echo "Create these labels or adjust the mapping to avoid runtime failures."
else
echo "All expected labels exist."
fiLength of output: 10146
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 확인: 워크플로우 트리거 이벤트 확인
echo "=== .github/workflows/label.yml 트리거 이벤트 (상위 30줄) ==="
sed -n '1,30p' .github/workflows/label.ymlLength of output: 884
라벨 유효성 확인 완료 & 포크 PR 토큰 권한 주의
- 검증 결과: 매핑된 모든 라벨이 리포지토리에 이미 존재합니다.
- 파일
.github/workflows/label.yml의 워크플로우가pull_request이벤트로 실행되기 때문에 포크에서 생성된 PR의 GITHUB_TOKEN은 읽기 전용이 되어 라벨 추가가 실패할 수 있습니다.
•on.pull_request를on.pull_request_target으로 변경하거나 별도의 워크플로우를 구성해 주세요.
🤖 Prompt for AI Agents
.github/workflows/label.yml around lines 42 to 52: the workflow runs on
pull_request so GITHUB_TOKEN is read-only for forked-PRs and the labels.add call
can fail; change the trigger to pull_request_target (or move labeling into a
separate repository-level workflow) so the action runs with repository write
permissions, ensure any inputs from the event payload are not trusted when using
pull_request_target, and verify label addition succeeds (or add error
handling/logging) after switching the trigger.
📌 Related Issues
✅ 체크 리스트
📄 Tasks
⭐ PR Point (To Reviewer)
📷 Screenshot
Summary by CodeRabbit