Github操作-在合并到主分支完成后自动将主分支合并到受保护的随机分支

vcirk6k6  于 2023-01-24  发布在  Git
关注(0)|答案(1)|浏览(215)

我想有一个github工作流合并主到我的分支名为开发后,公关合并。
推送到protected分支时出错-

remote: error: GH006: Protected branch update failed for refs/heads/develop.        
remote: error: At least 1 approving review is required by reviewers with write access.        
To https://github.com/blabla/blabla-repo
 ! [remote rejected] develop -> develop (protected branch hook declined)
error: failed to push some refs to 'https://github.com/blabla/blabla-repo'
Error: Process completed with exit code 1.

也许它没有使用管理员用户?我还添加了旁路选项..仍然得到错误..

name: Auto merge PR from main/master to develop branch
on:
  pull_request:
    branches:
      - main
      - master
    types: closed
jobs:
  merge-main-back-to-develop:
    if: github.event.pull_request.merged == true
    timeout-minutes: 2
    runs-on: ubuntu-latest
    env:
        GITHUB_TOKEN: ${{ secrets.adminUserToken }}
    steps:
      - uses: actions/checkout@v2
      - name: Set Git config
        run: |
          git config --local user.email "temp@temp.com"
          git config --local user.name "temp"
      - name: Merge main back to develop
        run: |
          git fetch --unshallow
          git checkout develop
          git pull
          git merge --no-ff ${{ github.base_ref }} -m "Auto-merge master/main back to develop"
          git push --force

我已经尝试使用此选项添加用户,但它仍然不起作用。

wydwbb8l

wydwbb8l1#

token下使用正确的权限配置PAT, checkout 步骤如下:

- uses: actions/checkout@v3
  with:
    token: ${{ secrets.adminUserToken }}

有关详细信息,请参阅用法。

相关问题