Skip to content

Instantly share code, notes, and snippets.

@duboisf
Created January 12, 2024 15:48
Show Gist options
  • Save duboisf/e63284c866b3171736c39e42b55c6eef to your computer and use it in GitHub Desktop.
Save duboisf/e63284c866b3171736c39e42b55c6eef to your computer and use it in GitHub Desktop.
Automate the approval of a bunch of GitHub pull requests

Sometimes in the course of your job you might need to approve a bunch of pull requests that were automatically created.

The gh cli is a handy tool to simplify this process.

In this example we'll approve all pull requests in the Foo org that request you as a reviewer and contains autoscaling:

for PR_URL in $(gh search prs org:Foo --review-requested @me --state open autoscaling --json url --jq ".[].url"); do
    echo $PR_URL
    gh pr review --approve $PR_URL
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment