From b69c23c88a7f4b99a640ef05a02ff90bf24d989b Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Sun, 24 May 2026 23:09:09 +0800 Subject: [PATCH] =?UTF-8?q?feat(deploy):=20=E9=83=A8=E7=BD=B2=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E5=90=8E=E5=8F=91=E9=80=81=20Telegram=20=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/deploy.yml | 7 +++++++ scripts/ci/notify.sh | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 scripts/ci/notify.sh diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 80efcf2..a3fcd9c 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -38,3 +38,10 @@ jobs: EC2_HOST: ${{ secrets.EC2_HOST }} EC2_USER: ${{ secrets.EC2_USER }} run: sh scripts/ci/deploy.sh "${{ gitea.ref_name }}" + + - name: Notify + if: always() + env: + TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} + TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} + run: sh scripts/ci/notify.sh "${{ gitea.ref_name }}" "${{ job.status }}" diff --git a/scripts/ci/notify.sh b/scripts/ci/notify.sh new file mode 100755 index 0000000..7a8b460 --- /dev/null +++ b/scripts/ci/notify.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# notify.sh — send Telegram deploy notification +set -euo pipefail + +TAG="$1" +STATUS="$2" + +if [ "$STATUS" = "success" ]; then + ICON="✅" + LABEL="部署成功" +else + ICON="❌" + LABEL="部署失败" +fi + +MSG="${ICON} 岩美 ${TAG} ${LABEL} +https://jiu.51yanmei.com" + +curl -sf -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage" \ + -d "chat_id=${TELEGRAM_CHAT_ID}" \ + --data-urlencode "text=${MSG}" \ + > /dev/null + +echo "==> notify: sent to Telegram (${STATUS})"