Repository navigation
90 lines (79 loc) · 2.58 KB
/
Copy pathmain.yml
File metadata and controls
90 lines (79 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: main PR -> Discord Notify
on:
pull_request:
types: [opened, reopened]
branches:
- main
permissions:
pull-requests: read
contents: read
jobs:
notify-discord:
if: ${{ !github.event.pull_request.draft }}
runs-on: ubuntu-latest
steps:
- name: Build Discord payload
id: payload
uses: actions/github-script@v7
with:
script: |
const pr = context.payload.pull_request;
const from = pr.head.ref;
const to = pr.base.ref;
const author = pr.user.login;
// Discord embed limits:
// - field value: 1024 chars (safe to truncate to 1000~1024)
const truncate = (text = '', max = 1024) => {
const t = String(text ?? '').trim();
if (!t) return '—';
return t.length > max ? `${t.slice(0, max - 1)}…` : t;
};
const prLink = pr.html_url;
const prBody = truncate(pr.body, 1024);
const payload = {
username: "🧚main 알림봇",
content: `\`${to}\`에 ${author}님이 PR을 등록했어요!`,
embeds: [
{
title: `🧡 PR #${pr.number} · ${pr.title}`,
url: prLink,
color: 16761035,
fields: [
{
name: "브랜치",
value: `From \`${from}\` → To \`${to}\``,
inline: false
},
{
name: "Author",
value: `**${author}**`,
inline: true
},
{
name: "PR 링크",
value: `[바로가기](${prLink})`,
inline: true
},
{
name: "PR 내용",
value: prBody,
inline: false
}
]
}
]
};
core.setOutput("json", JSON.stringify(payload));
- name: Send to Discord
env:
DISCORD_WEBHOOK_MAIN: ${{ secrets.DISCORD_WEBHOOK_MAIN }}
PAYLOAD: ${{ steps.payload.outputs.json }}
run: |
if [ -z "$DISCORD_WEBHOOK_MAIN" ]; then
echo "Missing DISCORD_WEBHOOK_MAIN secret"
exit 1
fi
curl -sSf -X POST \
-H "Content-Type: application/json" \
-d "$PAYLOAD" \
"$DISCORD_WEBHOOK_MAIN"