PR Workflow Automation
Beginner5 minTrending
Streamline pull request creation, review, and merging using GitHub CLI for faster code review cycles.
Prerequisites
- -GitHub CLI (gh) installed and authenticated
Steps
1
Create a pull request from the current branch
Open a PR with a title and body directly from the terminal.
$ gh pr create --title 'feat: add user authentication' --body 'Implements JWT-based auth with refresh tokens'
Use --draft to create a draft PR that is not ready for review yet.
2
List open pull requests
View all open PRs in the repository with status checks.
$ gh pr list --state open --json number,title,author,reviewDecision --jq '.[] | "#\(.number) \(.title) [\(.reviewDecision)]"'
3
Check out a PR locally for review
Fetch and check out a pull request branch to test it locally.
$ gh pr checkout 42
4
Approve and merge a PR
Submit an approval review and merge the PR in one flow.
$ gh pr review 42 --approve && gh pr merge 42 --squash --delete-branch
Use --squash for a clean history, --merge for a merge commit, or --rebase for a linear history.
Full Script
FAQ
Discussion
Loading comments...