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 "[email protected]"
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.
CodePudding user response:
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.