You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何触发Pull Request批准事件并获取批准者用户名?

GitHub Action PR批准事件触发与用户信息获取

触发Pull Request批准事件

你只需在GitHub上对目标Pull Request提交批准状态的评审即可触发该事件,具体操作:

  • 打开仓库中对应的Pull Request页面
  • 点击页面内的「Review changes」按钮
  • 在评审弹窗里选择「Approve」选项
  • 可填写评审备注,最后点击「Submit review」完成提交,此时就会触发配置中的pull_request_review事件(状态为approved)

获取批准PR的用户用户名

在GitHub Action的上下文变量中,批准该PR的用户信息存储在github.event.review.user对象里,用户名对应的字段是login。你需要将配置里的占位符替换为${{ github.event.review.user.login }},修改后的完整配置如下:

name: _On PR review
on:
  pull_request_review:
    types: [submitted]

jobs:
  approved:
    runs-on: [self-hosted]
    steps:
      - name: Send approved message to tg
        if: github.event.review.state == 'approved'
        with:
          silent_mode: "false"
          chat_id: ${{ secrets.PROJECT_CHAT_ID }}
          tg_url: ${{ secrets.TG_URL }}
          message: |
            Approved : ${{ github.event.review.user.login }}

内容的提问来源于stack exchange,提问作者Yuri Petrov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 20:46:01