Skip to content

Merge pull request #170 from Fanju6/chore/update-resources #16

Merge pull request #170 from Fanju6/chore/update-resources

Merge pull request #170 from Fanju6/chore/update-resources #16

Workflow file for this run

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 }})