Automate The Creation And Merge Of Pull Requests With gh cli & PowerShell

1. instructions

  • check if you are on a master branch
  • pull possible changes
  • checkout a new branch
  • do the work
  • stage -> commit -> push
  • create and merge the PR
if ("master" -ne ((git branch) -replace "\* ", "")) {git checkout master}
git pull origin
git checkout -b "JIRA-ID/foo_description"

# MAIN CODE CHANGING SOMETHING IN THE REPO

git add "foobar.json"
git commit -m "<ops> config change within foobar.json"
git push -u origin
gh pr create --fill
gh pr merge --merge --delete-branch
  • --fill helps not to prompt for title/body and just use commit info
  • --merge selects a merge commit, instead of rebase/squash options
  • optional --delete-branch Delete the local and remote branch after merge

2. sources

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pavol Kutaj

Pavol Kutaj

63 Followers

Infrastructure Support Engineer/Technical Writer (snowplow.io) with a passion for Python/writing documentation. More about me: https://pavol.kutaj.com