forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (48 loc) · 1.64 KB
/
Copy pathlesson-notify.yml
File metadata and controls
52 lines (48 loc) · 1.64 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
name: 新 Lesson 通知
on:
issues:
types: [opened, labeled]
permissions:
contents: read
issues: write
jobs:
notify:
if: contains(github.event.issue.labels.*.name, 'new-lesson') || contains(github.event.issue.title, 'new-lesson')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Send Feishu notification with retry
uses: ./.github/actions/retry/
with:
run: |
if [ -z "$WEBHOOK" ]; then
echo "No FEISHU_WEBHOOK_URL secret set — skipping notification"
exit 0
fi
SUMMARY=$(echo "$BODY" | head -5 | tr '\n' ' ' | cut -c1-200)
curl -s -X POST "$WEBHOOK" \
-H "Content-Type: application/json" \
-d "$(cat <<PAYLOAD
{
"msg_type": "interactive",
"card": {
"header": {
"title": {"tag": "plain_text", "content": "📘 新 Lesson 贡献"},
"template": "blue"
},
"elements": [
{"tag": "markdown", "content": "**贡献者:** $USER\n**标题:** $TITLE\n**摘要:** $SUMMARY\n**链接:** [查看详情]($URL)"}
]
}
}
PAYLOAD
)"
max_attempts: 3
backoff: exponential
backoff_base_seconds: 10
env:
WEBHOOK: ${{ secrets.FEISHU_WEBHOOK_URL }}
TITLE: ${{ github.event.issue.title }}
USER: ${{ github.event.issue.user.login }}
URL: ${{ github.event.issue.html_url }}
BODY: ${{ github.event.issue.body }}