Skip to content

[Feat] 채팅 줄바꿈 및 전체보기 기능 구현 #170

[Feat] 채팅 줄바꿈 및 전체보기 기능 구현

[Feat] 채팅 줄바꿈 및 전체보기 기능 구현 #170

name: Discord PR Merged Notification
on:
pull_request:
types: [closed]
permissions:
contents: read
pull-requests: read
jobs:
notify:
if: github.event.pull_request.merged == true
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 prAuthor = '${{ github.event.pull_request.user.login }}';
const mergedBy = '${{ github.event.pull_request.merged_by.login }}';
// Discord 멘션 생성 (모두에게)
const mentions = Object.values(discordIdMap)
.map(discordId => `<@${discordId}>`)
.join(' ');
// PR 본문에서 연결된 이슈 추출
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(', ')
: '연결된 이슈 없음';
// 리뷰어 목록 추출
const reviewers = context.payload.pull_request.requested_reviewers?.map(
reviewer => reviewer.login
) || [];
const reviewerText = reviewers.length > 0
? reviewers.map(username => `@${username}`).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: 8311585, // 보라색 (hex를 decimal로: #7E57C1)
thumbnail: {
url: context.payload.pull_request.user.avatar_url
},
fields: [
{
name: '✍️ 작성자',
value: prAuthor,
inline: true
},
{
name: '🔀 머지한 사람',
value: mergedBy,
inline: true
},
{
name: '🌿 브랜치',
value: `\`${context.payload.pull_request.head.ref}\` → \`${context.payload.pull_request.base.ref}\``,
inline: false
},
],
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)
});