Skip to content

Shell script to automatically rebase and merge your PRs when they are out-of-date

Notifications You must be signed in to change notification settings

xmac11/merge-it

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

merge-it

Shell script to automatically rebase and merge your PRs when they are out-of-date

Requirements

Getting Started

  • Clone this repository
git clone https://github.com/xmac11/merge-it.git
  • Set the GH_TOKEN environment variable

For example, if you are using zsh:

echo 'export GH_TOKEN=your-token' >> ~/.zprofile
  • Create a cron job

Run:

crontab -e

and schedule the cron job. For example, if you are using zsh and you want to merge feature-branch into develop for a repository named my-repo owned by my-company:

* * * * * source ~/.zprofile; /path/to/script/merge_it.sh /path/to/repo my-company my-repo develop feature-branch >> /path/to/script/mergeit.log 2>&1

Pop-up notifications (macOS)

Successful merge

image

Successful rebase

image

Merge conflict

image

Failed pipeline

image

Notes

  1. A PR must have been already opened manually.
  2. A single PR must exist for a given branch.
  3. The first time the script runs, it enables auto-merge. However, if you disable it, you will have to re-enable it manually.
  4. When the branch is merged, running the script will do nothing. Nonetheless, you should remove the cron job. Ideally, this would be done automatically, and might be added in the future.

Troubleshooting

  1. (macOS) Operation not permitted when cron runs the script
    Give cron Full Disc Access (source)

  2. gh: command not found when cron runs the script
    Make sure that GitHub CLI is installed and present in the PATH when the cron job runs.
    For example, if the GitHub CLI was installed with Homebrew and you are using zsh:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile 

About

Shell script to automatically rebase and merge your PRs when they are out-of-date

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages