refactor: 改用纯 curl 命令发送邮件,去掉外部 Action 依赖
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 10m55s

This commit is contained in:
2026-04-22 12:52:04 +08:00
parent 6448475145
commit 757b82b704

View File

@@ -95,46 +95,50 @@ jobs:
cd docker cd docker
docker compose ps docker compose ps
- name: 发送邮件通知(成功) - name: 发送成功通知邮件
if: success() if: success()
uses: dawidd6/action-send-mail@v3 env:
with: MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }}
server_address: smtp.qq.com MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }}
server_port: 587 MAIL_TO: ${{ secrets.MAIL_TO }}
username: ${{ secrets.MAIL_USERNAME }} run: |
password: ${{ secrets.MAIL_PASSWORD }} if [ -z "$MAIL_USERNAME" ] || [ -z "$MAIL_PASSWORD" ] || [ -z "$MAIL_TO" ]; then
subject: "✅ AI Agent 构建成功 - ${{ github.repository }}" echo "⚠️ 邮件 Secrets 未配置,跳过发送邮件"
body: | exit 0
构建成功! fi
仓库: ${{ github.repository }} SUBJECT="✅ AI Agent 构建成功 - ${{ github.repository }}"
分支: ${{ github.ref }} 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 }}"
提交: ${{ github.sha }}
提交者: ${{ github.actor }}
提交信息: ${{ github.event.head_commit.message }}
查看详情: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} echo "📧 发送成功通知邮件..."
to: ${{ secrets.MAIL_TO }}
from: GitHub Actions <${{ secrets.MAIL_USERNAME }}>
- name: 发送邮件通知(失败) 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: 发送失败通知邮件
if: failure() if: failure()
uses: dawidd6/action-send-mail@v3 env:
with: MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }}
server_address: smtp.qq.com MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }}
server_port: 587 MAIL_TO: ${{ secrets.MAIL_TO }}
username: ${{ secrets.MAIL_USERNAME }} run: |
password: ${{ secrets.MAIL_PASSWORD }} if [ -z "$MAIL_USERNAME" ] || [ -z "$MAIL_PASSWORD" ] || [ -z "$MAIL_TO" ]; then
subject: "❌ AI Agent 构建失败 - ${{ github.repository }}" echo "⚠️ 邮件 Secrets 未配置,跳过发送邮件"
body: | exit 0
构建失败! fi
仓库: ${{ github.repository }} SUBJECT="❌ AI Agent 构建失败 - ${{ github.repository }}"
分支: ${{ github.ref }} 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 }}"
提交: ${{ github.sha }}
提交者: ${{ github.actor }}
提交信息: ${{ github.event.head_commit.message }}
查看详情: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} echo "📧 发送失败通知邮件..."
to: ${{ secrets.MAIL_TO }}
from: GitHub Actions <${{ secrets.MAIL_USERNAME }}> 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")