This is a webhook that protects your master branch on GitHub from pushes. Only pull-requests will get into your master branch.
Pushes to master are moved to a branch, then a pull request is automatically created.
This is the easy way (that gives me access to anything).
- Add
pull-to-master-bot
as a collaborator to your repository. - Add a webhook with the url
https://pull-to-master.herokuapp.com/webhook
and payload version ofapplication/vnd.github.v3+json
- Install Heroku
- Clone this application.
git clone https://github.com/terite/pull-to-master.git; cd pull-to-master
- Create a Heroku app
heroku create
- Configure.
heroku config:set GH_USER=... GH_PASS=...
- Push to Heroku
git push heroku master
This project requires a GitHub user to operate as. This can be your own user, or a user created specifically for this webhook.
If you want to use a personal access token as a password, it needs to have scopes repo and public_repo.
- Recent version of node.js.
- GitHub user with access to your repositories
- Some Node.js host. I use Heroku, others work too.
-
Set environment variables
GH_USER
andGH_PASS
to your github user's username and password. This user needs to have permission to all repositories that it manages. -
Run
node hook-listener.js
Have foreman? instead runforeman start
.
- GitHub webhooks lets it know about any pushes.
- If push is a pull request merge, allow it. Otherwise, continue to 3.
- Make a new branch with pushed commits
- Roll back master to previous state.
- Make a pull request from new branch to master.