I am using GitHub Actions to increment my angular project version as a last step in my workflow. I configured the git user and git email before pushing (i.e, before running 'git push').
git config user.name "${{ secrets.GIT_USER }}"
git config user.email "${{ secrets.GIT_EMAIL }}"
I am getting below error
remote: error: GH006: Protected branch update failed for refs/heads/development.
remote:
remote: - Changes must be made through a pull request.
To https://github.com/my-repo-name.git
! \[remote rejected\] development -\> development (protected branch hook declined)
error: failed to push some refs to 'https://github.com/my-repo-name.git'
I realised am not using any password or Git PAT for pushing so tried setting the git remote url as below
git remote set-url origin https://x-access-token:${{ secrets.GIT_TOKEN }}@github.com/thermofisher/de-instrument-storage-service.git
Additional context:
My repo is a private repo.
The branch ('development') I am trying to push has branch protection rule called Require a pull request before merging checked. Which I should not disable. And also the git user and email that I'm using have admin permission for the repository. So not sure why I am unable to push!
Is there any way, to be able to push changes via GitHub Actions to a protected branch as an admin?
I had to pass the GIT Personal Access Token while cloning the repo..
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GIT_TOKEN }}
From then on I am able to commit/push with the git user which has admin access to the repo and effectively able to bypass the "Require a pull request before merging" check.
I referred to the following: https://www.paulmowat.co.uk/blog/resolve-github-action-gh006-protected-branch-update-failed