Can you use GitHub Action account to approve PRs?

I have a repository and want to enforce a branch system by having the master branch protected and requiring at least 1 approving review for the Pull request to be mergeable.

Right now am I the only person contributing to the project and I (ab)use my admin privileges to bypass this approval-requirement since I can’t approve my own PRs (Can I tho? Like is there a way?)
However, I don’t like this as it feels a bit cheaty and I want to prevent others with those rights to easily bypass this since the project is part of an org.

My question now is, if I can use the GitHub Actions account to approve the changes, so that the PR would become mergeable.
If that is doable would I like to use a System with either assigning a label (Something like “Action: Auto-Approve”) or writing a comment like “pls approve” to make the action then approve the PR.

I hope that there is a solution for this. Thanks in advance for any solutions.

I don’t think so. At least the GitHub web interface does not let you do that. I’m not sure if the API might allow it.

I want to prevent others with [admin privileges] to easily bypass this [approval-requirement]

As I understand, you still want to be able to bypass the approval process for yourself. Are you an administrator too or the owner of the repo? I suppose that the owner can still bypass the approval even if they are mandatory for admins (“Include administrators” at the bottom):

If that doesn’t work for you, then yes, you can let a workflow approve your pull requests, e.g. using the github-script action:

name: PR Approval

on:
  pull_request:
    branches:
      - master
  types: [opened] # probably the only one you need

jobs:
  build:
    name: Auto-approve
    runs-on: ubuntu-latest
    if: github.event.pull_request.user.login == 'andre601'
    steps:
      - uses: actions/github-script@v4
        with:
          script: |
            const result = await github.pulls.createReview({
              owner: context.repo.owner,
              repo: context.repo.repo,
              pull_number: context.issue.number,
              event: "APPROVE"
            })
            console.log(result.status)

image

You may need to restrict who can approve PRs though. I saw spam bots randomly approving PRs in public repos, for instance.

I used a action for auto-approving Prs with an if statement and works fine. Thanks for the info and clarification tho.