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
github-actions
bot is able to approve it (but for some reason, not to merge it) – Kurzawa--admin
flag from thegh pr merge
command? As far as I know, GH action cannot perform admin tasks with their default GH_TOKEN. – Clotho--auto
flag? – Clotho--auto
and--admin
cannot be combinedspecify only one of
--auto,
--disable-auto, or
--admin`` – Kurzawa--auto
flag. In addition, what requirements do you have set for the branch policy? – Clotho