Skip to content

[Fix] group (모임상세) 컴포넌트 하위경로에 pending 컴포넌트 중복 파일 제거 #194

[Fix] group (모임상세) 컴포넌트 하위경로에 pending 컴포넌트 중복 파일 제거

[Fix] group (모임상세) 컴포넌트 하위경로에 pending 컴포넌트 중복 파일 제거 #194

name: Discord PR Review Ready Mention
on:
pull_request:
types: [labeled]
permissions:
contents: read
pull-requests: read
jobs:
notify:
if: github.event.label.name == 'Ready For Review!'
runs-on: ubuntu-latest
steps:
- name: Send Discord notification
uses: actions/github-script@v8
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_ID_MAP: ${{ secrets.DISCORD_ID_MAP }}
with:
script: |
// PR 생성한 유저의 디스코드ID 추출
const discordIdMap = JSON.parse(process.env.DISCORD_ID_MAP);
const githubUser = '${{ github.event.pull_request.user.login }}';
const myDiscordId = discordIdMap[githubUser];
// discordIdMap에 등록된 모든 유저의 Github username 추출
const everyone = Object.keys(discordIdMap) || [];
// PR에 지정된 리뷰어들의 GitHub username 추출
const reviewers = context.payload.pull_request.requested_reviewers?.map(
reviewer => reviewer.login
) || [];
// Discord 멘션 생성 (모두에게)
const mentions = Object.values(discordIdMap)
.map(discordId => `<@${discordId}>`)
.join(' ');
// 담당 리뷰어 텍스트 생성
const reviewerText = reviewers.length > 0
? reviewers.map(username => `@${username}`).join(', ')
: '지정되지 않음';
// PR 본문에서 연결된 이슈 추출 (예: #123, Closes #123, Fixes #123 등)
const prBody = context.payload.pull_request.body || '';
const issueMatches = prBody.match(/#(\d+)/g);
const linkedIssues = issueMatches
? issueMatches.map(match => `[${match}](${context.payload.repository.html_url}/issues/${match.slice(1)})`).join(', ')
: '연결된 이슈 없음';
// Discord 웹훅 전송
const payload = {
content: `${mentions}\n\nPR 리뷰 받을 준비가 완료됐어요! 🚀`,
embeds: [{
title: `#${context.payload.pull_request.number} ${context.payload.pull_request.title}`,
url: context.payload.pull_request.html_url,
description: `🔗 **연결된 이슈**: ${linkedIssues}\n👥 **담당 리뷰어**: ${reviewerText}`,
color: 5763719, // 색상 (hex를 decimal로: #57F287 = 초록)
thumbnail: {
url: context.payload.pull_request.user.avatar_url // 작성자 프로필 이미지
},
fields: [
{
name: '👤 작성자',
value: context.payload.pull_request.user.login,
inline: true
},
{
name: '🌿 브랜치',
value: `\`${context.payload.pull_request.head.ref}\``,
inline: true
},
{
name: '📊 변경사항',
value: `+${context.payload.pull_request.additions} -${context.payload.pull_request.deletions}`,
inline: true
}
],
footer: {
text: 'WeGo PR Review System',
icon_url: 'https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png'
},
timestamp: new Date().toISOString()
}]
};
await fetch(process.env.DISCORD_WEBHOOK, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});