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

如何将开源项目自动PR的发起者改为github-actions?

如何让GitHub Actions自动发起的PR以github-actions作为发起者
  • 检查Workflow使用的身份凭证:
    若PR发起者显示为管理员账号,通常是因为你在Workflow中使用了**个人访问令牌(PAT)**而非GitHub官方提供的GITHUB_TOKEN。官方GITHUB_TOKEN默认会以github-actions[bot]身份执行操作。

  • 替换为GITHUB_TOKEN并配置权限:
    在生成PR的步骤中,将自定义令牌替换为${{ secrets.GITHUB_TOKEN }},同时在Workflow开头配置足够的权限。以actions/create-pull-request动作为例:

    name: Auto Generate PR
    on: [push]
    
    permissions:
      contents: write
      pull-requests: write
    
    jobs:
      create-pr:
        runs-on: ubuntu-latest
        steps:
          - name: Checkout code
            uses: actions/checkout@v4
          
          # 这里添加你的代码修改步骤
          
          - name: Create Pull Request
            uses: actions/create-pull-request@v4
            with:
              token: ${{ secrets.GITHUB_TOKEN }}
              title: "Auto-generated: Update [内容描述]"
              branch: "auto-update-branch"
    
  • 修正Git用户配置(若有):
    如果Workflow中手动设置了Git用户信息,需改为github-actions的官方身份:

    git config --global user.name "github-actions[bot]"
    git config --global user.email "github-actions[bot]@users.noreply.github.com"
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 10:45:41