GitHub Actions + pushplus:构建结果推到微信
效果:工作流成功或失败后,微信收到一条摘要。不要在每一步都推,结束时发 1 条即可。
前置条件
- 一个 pushplus token(官网扫码获取)
- 仓库的 Actions 写权限
配置步骤
- 仓库 Settings → Secrets and variables → Actions,新增
PUSHPLUS_TOKEN,值为你的 token。 - 在工作流末尾增加通知 job,仅失败或始终在结束时执行:
notify:
if: always()
needs: [build]
runs-on: ubuntu-latest
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\":\"GitHub Actions ${{ github.repository }}\",
\"content\":\"workflow=${{ github.workflow }}\\nresult=${{ job.status }}\\nref=${{ github.ref_name }}\\nrun=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\",
\"template\":\"markdown\"
}"
- 提交后手动 Run 一次,或等下一次 push。
验证
本地先确认 token:
curl -X POST "https://www.pushplus.plus/send" \
-H "Content-Type: application/json" \
-d '{"token":"你的token","title":"GitHub Actions 配置测试","content":"token 可用","template":"markdown"}'
常见问题
Secret 没带上? Fork 仓库的 PR 默认读不到你的 Secret。用 workflow_dispatch 或本仓库分支验证。
只想失败才推? 把 if: always() 改成 if: failure()。