-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (73 loc) · 2.81 KB
/
Copy pathci.yml
File metadata and controls
86 lines (73 loc) · 2.81 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
name: 持续集成(构建与开发包)
on:
workflow_dispatch:
push:
branches: [main]
paths:
- 'src/module/**'
- 'src/webui/**'
- '.github/workflows/ci.yml'
- '.github/actions/build-module/**'
permissions:
contents: read
# 同一分支的新推送取消尚未完成的旧构建
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: 构建与推送开发包
runs-on: ubuntu-latest
steps:
- name: 拉取代码
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: 构建并打包模块
id: pack
uses: ./.github/actions/build-module
- name: 推送开发包到 Telegram
env:
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }}
TG_CHAT_ID: ${{ secrets.TG_CHAT_ID }}
COMMIT_MSG: ${{ github.event.head_commit.message }}
VERSION: ${{ steps.pack.outputs.version }}
COMMIT_COUNT: ${{ steps.pack.outputs.commit_count }}
FULL_NAME: ${{ steps.pack.outputs.full_name }}
LITE_NAME: ${{ steps.pack.outputs.lite_name }}
MINI_NAME: ${{ steps.pack.outputs.mini_name }}
run: |
CAPTION="模块构建成功通知
版本: \`${VERSION}\` (build ${COMMIT_COUNT})
说明:
\`\`\`
${COMMIT_MSG:-手动触发或无说明}
\`\`\`
[提交记录](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})
[构建日志](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
# 统一发送函数:$1=文件 $2=说明,其余参数透传给 curl(如 -F parse_mode=Markdown)
send() {
curl -sS \
-F "chat_id=${TG_CHAT_ID}" \
-F "message_thread_id=2275" \
-F "document=@$1" \
-F "caption=$2" \
"${@:3}" \
"https://api.telegram.org/bot${TG_BOT_TOKEN}/sendDocument"
}
send "$FULL_NAME" "$CAPTION" -F "parse_mode=Markdown"
send "$LITE_NAME" "lite: 不含 IPSET 驱动,适用于内核已内置 IPSET 的设备"
send "$MINI_NAME" "mini: 不含二进制文件和 IPSET 驱动,需自行放入 sing-box、proxylink、zashboard 等组件"
- name: 失败通知
if: failure()
uses: cbrgm/telegram-github-action@v1
with:
token: ${{ secrets.TG_BOT_TOKEN }}
to: ${{ secrets.TG_CHAT_ID }}
thread-id: 2275
parse-mode: markdown
message: |
**持续集成失败!**
提交: `${{ github.sha }}`
说明: ${{ github.event.head_commit.message }}
[点击查看构建日志](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})