From ae4c4070da0e383288259a2aed5a24e932c07392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=83=E7=9F=B3?= Date: Sat, 4 Jan 2025 11:12:27 +0800 Subject: [PATCH 1/3] Create feishu_notify.sh --- feishu_notify.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 feishu_notify.sh diff --git a/feishu_notify.sh b/feishu_notify.sh new file mode 100644 index 0000000..9639bb0 --- /dev/null +++ b/feishu_notify.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# 参数获取 +WEBHOOK_URL="$1" +TITLE="$2" +CONTENT="$3" + +# 飞书通知 +send_feishu_notification() { + local message=$(cat < Date: Sat, 4 Jan 2025 11:13:00 +0800 Subject: [PATCH 2/3] Update config.sh --- config.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config.sh b/config.sh index caa5443..19d7278 100644 --- a/config.sh +++ b/config.sh @@ -22,6 +22,10 @@ SMTP_PASS=${SMTP_PASS:-""} MAIL_TO=${MAIL_TO:-""} MAIL_FROM=${MAIL_FROM:-"$SMTP_USER"} +# 飞书通知配置 +ENABLE_FEISHU=${ENABLE_FEISHU:-"false"} +FEISHU_WEBHOOK_URL=${FEISHU_WEBHOOK_URL:-""} + # 跳过的仓库 SKIP_REPOS=${SKIP_REPOS:-"archive,AutoApiSecret, \ backup-openbilibili-go-common, \ From 094fb11580fc71e387b4555416350e61cb47237a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=83=E7=9F=B3?= Date: Sat, 4 Jan 2025 11:14:58 +0800 Subject: [PATCH 3/3] Update main.sh --- main.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/main.sh b/main.sh index f843183..d20a9ba 100644 --- a/main.sh +++ b/main.sh @@ -111,10 +111,23 @@ $(cat "$LOG_FILE") "$summary" fi + # 准备飞书通知内容 + feishu_title="GitHub 同步$([ $mirror_exit_code -eq 0 ] && echo "成功" || echo "失败")" + feishu_content="GitHub to Gitea 同步报告\n\n$(tail -n 50 "$LOG_FILE")" + + # 如果启用了飞书通知,调用 feishu_notify.sh + if [ "$ENABLE_FEISHU" = "true" ]; then + bash "$SCRIPT_DIR/feishu_notify.sh" \ + "$FEISHU_WEBHOOK_URL" \ + "$feishu_title" \ + "$feishu_content" + fi + + # 清理工作目录 [ -d "$WORK_DIR" ] && rm -rf "$WORK_DIR" exit $mirror_exit_code } -main "$@" \ No newline at end of file +main "$@"