From 6f4c3a3e21a943cd456c6f10c7e4411a56596f6f Mon Sep 17 00:00:00 2001
From: "tao.chen" <93983997+taochen-ct@users.noreply.github.com>
Date: Wed, 15 Jul 2026 16:36:07 +0800
Subject: [PATCH] =?UTF-8?q?ci:=20Bark=20=E6=8E=A8=E9=80=81=E9=80=BB?=
=?UTF-8?q?=E8=BE=91=E6=8F=90=E5=88=B0=E7=8B=AC=E7=AB=8B=E8=84=9A=E6=9C=AC?=
=?UTF-8?q?,=20=E4=B8=A4=20job=20=E5=A4=8D=E7=94=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
之前 ci/release 各自 inline 拼 payload + curl, 重复 25 行 x 2.
device_key / endpoint / group / ttl 硬编码两次, 改一处忘另一处
会出现两个不同 group 的推送.
新建 .github/scripts/bark-notify.sh:
bash .github/scripts/bark-notify.sh "
" ""
脚本封装:
- endpoint / device_key / group (Gitea) / isArchive / ttl 单一来源
- heredoc 拼 JSON, 不依赖 jq
- 错误用法打印 usage 并 exit 1 (set -euo pipefail)
workflow 两处都改成一行:
bash .github/scripts/bark-notify.sh "CI \${REF_NAME} \${STATUS}" "\${BODY}"
bash .github/scripts/bark-notify.sh "\${TAG_NAME} \${STATUS}" "\${BODY}"
emoji (✅/❌) 跟 status 映射仍在 workflow 里, 因为不同 job 拼
不同的 title prefix (CI vs release), 脚本不管这个, 调用方传什么
就推什么.
chmod +x 加在 commit 里, 但 git mode bit 在 .gitattributes 或
core.fileMode 关时可能丢. runner 一般会按 working tree 模式跑,
不需要额外 chmod 在 step 里.
Co-Authored-By: Claude
---
.github/scripts/bark-notify.sh | 37 ++++++++++++++++++++++++++++++++++
.github/workflows/build.yml | 32 ++---------------------------
2 files changed, 39 insertions(+), 30 deletions(-)
create mode 100755 .github/scripts/bark-notify.sh
diff --git a/.github/scripts/bark-notify.sh b/.github/scripts/bark-notify.sh
new file mode 100755
index 0000000..e1013ee
--- /dev/null
+++ b/.github/scripts/bark-notify.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+# bark-notify.sh — push a notification to the local Bark server.
+#
+# Usage: bark-notify.sh
+#
+# The Bark endpoint, device_key, and group are pinned in this script
+# (it is a deployment detail, not a secret). The group is "Gitea" —
+# change it here if you want to sort notifications by category.
+
+set -euo pipefail
+
+if [ "$#" -ne 2 ]; then
+ echo "usage: $0 " >&2
+ exit 1
+fi
+
+TITLE="$1"
+BODY="$2"
+
+PAYLOAD=$(cat <