I have configured my repository so that GitHub actions are able to approve PRs
I have branch protection rule, requiring 1 approval before merging.
However the following step fails
- name: perform the merge if applicable
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
echo "Approving PR..."
gh pr review --approve ${{ github.event.issue.number }}
echo "Merging PR..."
gh pr merge ${{ github.event.issue.number }} --admin --squash
(the PR is indeed approve but the merge fails)
Approving PR...
Merging PR...
Message: You're not authorized to push to this branch. Visit https://docs.github.com/articles/about-protected-branches/ for more information., Locations: [{Line:1 Column:58}]
How can I allow github-actions
bot to also merge the PR?
update 1
after removing the --admin
flag, just in case
Approving PR...
Merging PR...
X Pull request #199 is not mergeable: the base branch policy prohibits the merge.
To have the pull request merged after all the requirements have been met, add the `--auto` flag.
To use administrator privileges to immediately merge the pull request, add the `--admin` flag.
update 2
I have added the following permissions to the GITHUB_ACTIONS
token, without any effect whatsoever
permissions:
contents: write
pull-requests: write
repository-projects: write