Gitea + pushplus:仓库事件与 Actions 结果通知
效果:Push、PR 或 Actions 失败时,微信收到提醒。动态内容用 Actions;固定文案可用仓库 Webhook。
前置条件
- 一个 pushplus token(官网扫码获取)
- 仓库管理员,或能改
.gitea/workflows的权限
Gitea Webhook POST 的 JSON 不会自动变成正文。
配置步骤
方式一:Actions 动态内容(推荐)
在仓库 Settings → Actions / Secrets 添加 PUSHPLUS_TOKEN(Masked)。工作流结束时:
notify:
if: always()
needs: [build]
steps:
- name: notify pushplus
run: |
curl -s -X POST "https://www.pushplus.plus/send" \
-H "Content-Type: application/json" \
-d "{\"token\":\"${{ secrets.PUSHPLUS_TOKEN }}\",\"title\":\"Gitea ${{ github.repository }}\",\"content\":\"result=${{ job.status }}\\nref=${{ github.ref_name }}\",\"template\":\"markdown\"}"
变量名以你使用的 Gitea Actions 运行时为准,可把 commit、job 名拼进 content。只想失败才推时,把 if 改成 failure()。
方式二:仓库 Webhook 固定文案
仓库 Settings → Webhooks,URL 填:
https://www.pushplus.plus/send?token=你的token&title=Gitea有新事件&content=请打开Gitea查看
勾选 Push、Pull Request、Workflow 等事件。此方式只有固定文案。
完整参数见 消息接口文档。
验证
curl -X POST "https://www.pushplus.plus/send" \
-H "Content-Type: application/json" \
-d '{"token":"你的token","title":"Gitea 配置测试","content":"token 可用","template":"markdown"}'
返回 code 为 200 后,再在 Webhook 页点测试,或手动跑一次 Actions。
常见问题
Webhook 测试没有分支名? 这是预期行为。要动态正文请用方式一。
Actions 里 curl 失败? 确认 Runner 能访问 www.pushplus.plus,且 Secret 已注入。
收不到消息见 排查说明。