A GitHub bot that rebases your pull request branches when you ask
- Make a dedicated GitHub account for the bot
- Grant the GitHub account read and write access to your repositories
- Setup the bot on your own server
- Type a comment "@{github bot username} rebase" in a pull request
- The bot will then kick off a rebase and push (if rebase successful) to your repository
- You can then delete the comment (in step 4) if you want to, including the rebase comment from the bot.
- Dedicated host (e.g. EC2, Digital Ocean, Rackspace)
- Go 1.5
- Git
- Dedicated GitHub account
$ go get github.com/chrisledet/rebasebot
$ cd $GOPATH/src/github.com/chrisledet/rebasebot
$ go build
Make sure $GOPATH/bin
is located in your $PATH
$ go install
Here are the environment variables rebasebot uses:
GITHUB_USERNAME
: GitHub username for bot. Required.GITHUB_PASSWORD
: GitHub password for bot. Required.PORT
: HTTP server port for the bot. Required.TMPDIR
: A path to a writable directory. All local copies will live here. Defaults to OS tmp. Strongly recommended.SECRET
: A token used to verify web hook requests from GitHub. Strongly recommended.
The GITHUB_*
are needed so the bot can post activity updates to GitHub as well as push to accessible Git repositories. Using your personal credentials is not recommended.
$ $GOPATH/bin/rebasebot
This is a required step to complete the setup.
- Go into your GitHub repository's Webhooks and services page
- Add webhook
- Enter
http://<your host>/rebase
in the "Payload URL" field - Content type should be set to "application/json"
- Generate a secret token and enter it in "Secret" field
- Only send "Issue comment" events. All other ones will be ignored.
- GitHub should succesfully ping the service and receive a HTTP 200 OK
-
GitHub guide for securing your webhooks
-
Generate secret token with Ruby
$ ruby -rsecurerandom -e 'puts SecureRandom.hex(20)'