refactor: 改用纯 curl 命令发送邮件,去掉外部 Action 依赖
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 10m55s
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 10m55s
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user