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

Github Actions问候Bot无法在PR提交时添加评论求助

问题排查与解决方案

核心原因

actions/first-interaction@v1 这个Action的设计逻辑是仅向仓库的首次贡献者(第一次提交PR或创建Issue的用户)发送问候消息。如果提交PR的用户之前已经在该仓库有过PR、Issue提交记录,或者是仓库维护者,这个Action就不会生成评论——哪怕工作流显示执行成功。

验证方法

  • 检查提交PR的用户的仓库贡献记录:确认该用户是否有过历史PR、Issue,或是仓库成员。
  • 用新账号测试:找一个从未在该仓库有过任何操作的GitHub账号提交PR,验证是否能正常生成问候评论。

替代方案(给所有PR发送问候)

如果需要给**所有提交PR的用户(无论是否首次贡献)**发送问候评论,可以替换为actions/github-script实现,示例配置如下:

name: Greetings

on: 
  pull_request_target:
    types: [opened]

jobs:
  greeting:
    runs-on: ubuntu-latest
    steps:
      - name: Greet PR Submitter
        uses: actions/github-script@v6
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          script: |
            github.rest.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: `Hello @${context.actor}, thank you for submitting a PR! To allow your work to be integrated as seamlessly as possible, we advise you to:
              - Verify your PR is **up-to-date with origin/master.** 
              - Verify all Continuous Integration (CI) **checks are passing**.
              - Reduce changes to the absolute **minimum** required for your bug fix or feature addition. _"It is not daily increase but daily decrease, hack away the unessential." - Bruce Lee._`
            })

额外注意事项

  • 明确指定pull_request_target的触发类型为opened,可以避免PR状态变更时重复执行工作流。
  • 默认的GITHUB_TOKEN已经拥有评论PR的权限,无需额外配置权限。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.17 21:33:11