简体   繁体   中英

Github Actions - Auto-merge main to protected random branch after merge to main completed

I want to have a github workflow to merge main to my branch named develop after PR merged.

I have an error of pushing to protected branch -

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.

Maybe its not using the admin user? I've also added the bypass option.. Still getting the error..

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

I have tried adding the user with this option but it still doesn't work.

在此处输入图像描述

Configure your PAT with the right permissions under token with your checkout step like this:

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

See Usage for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM