From 757b82b70424f8949bbbc59209b10f514b76f240 Mon Sep 17 00:00:00 2001 From: root <953994191@qq.com> Date: Wed, 22 Apr 2026 12:52:04 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=94=B9=E7=94=A8=E7=BA=AF=20curl?= =?UTF-8?q?=20=E5=91=BD=E4=BB=A4=E5=8F=91=E9=80=81=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E5=8E=BB=E6=8E=89=E5=A4=96=E9=83=A8=20Action=20?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/deploy.yml | 84 +++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 582843b..2510fb1 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -95,46 +95,50 @@ jobs: cd docker docker compose ps - - name: 发送邮件通知(成功) + - name: 发送成功通知邮件 if: success() - uses: dawidd6/action-send-mail@v3 - with: - server_address: smtp.qq.com - server_port: 587 - username: ${{ secrets.MAIL_USERNAME }} - password: ${{ secrets.MAIL_PASSWORD }} - subject: "✅ AI Agent 构建成功 - ${{ github.repository }}" - body: | - 构建成功! - - 仓库: ${{ github.repository }} - 分支: ${{ github.ref }} - 提交: ${{ github.sha }} - 提交者: ${{ github.actor }} - 提交信息: ${{ github.event.head_commit.message }} - - 查看详情: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - to: ${{ secrets.MAIL_TO }} - from: GitHub Actions <${{ secrets.MAIL_USERNAME }}> + env: + MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }} + MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }} + MAIL_TO: ${{ secrets.MAIL_TO }} + run: | + if [ -z "$MAIL_USERNAME" ] || [ -z "$MAIL_PASSWORD" ] || [ -z "$MAIL_TO" ]; then + echo "⚠️ 邮件 Secrets 未配置,跳过发送邮件" + exit 0 + fi + + SUBJECT="✅ AI Agent 构建成功 - ${{ github.repository }}" + BODY="构建成功!\n\n仓库: ${{ github.repository }}\n分支: ${{ github.ref }}\n提交: ${{ github.sha }}\n提交者: ${{ github.actor }}\n提交信息: ${{ github.event.head_commit.message }}\n\n查看详情: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + + echo "📧 发送成功通知邮件..." + + curl --url "smtps://smtp.qq.com:465" \ + --ssl-reqd \ + --mail-from "$MAIL_USERNAME" \ + --mail-rcpt "$MAIL_TO" \ + --user "$MAIL_USERNAME:$MAIL_PASSWORD" \ + --upload-file <(echo -e "From: GitHub Actions <$MAIL_USERNAME>\nTo: $MAIL_TO\nSubject: $SUBJECT\n\n$BODY") - - name: 发送邮件通知(失败) + - name: 发送失败通知邮件 if: failure() - uses: dawidd6/action-send-mail@v3 - with: - server_address: smtp.qq.com - server_port: 587 - username: ${{ secrets.MAIL_USERNAME }} - password: ${{ secrets.MAIL_PASSWORD }} - subject: "❌ AI Agent 构建失败 - ${{ github.repository }}" - body: | - 构建失败! - - 仓库: ${{ github.repository }} - 分支: ${{ github.ref }} - 提交: ${{ github.sha }} - 提交者: ${{ github.actor }} - 提交信息: ${{ github.event.head_commit.message }} - - 查看详情: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - to: ${{ secrets.MAIL_TO }} - from: GitHub Actions <${{ secrets.MAIL_USERNAME }}> + env: + MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }} + MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }} + MAIL_TO: ${{ secrets.MAIL_TO }} + run: | + if [ -z "$MAIL_USERNAME" ] || [ -z "$MAIL_PASSWORD" ] || [ -z "$MAIL_TO" ]; then + echo "⚠️ 邮件 Secrets 未配置,跳过发送邮件" + exit 0 + fi + + SUBJECT="❌ AI Agent 构建失败 - ${{ github.repository }}" + BODY="构建失败!\n\n仓库: ${{ github.repository }}\n分支: ${{ github.ref }}\n提交: ${{ github.sha }}\n提交者: ${{ github.actor }}\n提交信息: ${{ github.event.head_commit.message }}\n\n查看详情: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + + echo "📧 发送失败通知邮件..." + + curl --url "smtps://smtp.qq.com:465" \ + --ssl-reqd \ + --mail-from "$MAIL_USERNAME" \ + --mail-rcpt "$MAIL_TO" \ + --user "$MAIL_USERNAME:$MAIL_PASSWORD" \ + --upload-file <(echo -e "From: GitHub Actions <$MAIL_USERNAME>\nTo: $MAIL_TO\nSubject: $SUBJECT\n\n$BODY")