Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s4heid/branch-switcher
a GitHub bot that switches the base branch of pull requests to the preferred branch
https://github.com/s4heid/branch-switcher
branches github-app probot probot-app pull-requests typescript
Last synced: 4 months ago
JSON representation
a GitHub bot that switches the base branch of pull requests to the preferred branch
- Host: GitHub
- URL: https://github.com/s4heid/branch-switcher
- Owner: s4heid
- License: apache-2.0
- Created: 2019-06-12T19:41:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T03:55:05.000Z (almost 2 years ago)
- Last Synced: 2024-09-27T08:02:26.775Z (4 months ago)
- Topics: branches, github-app, probot, probot-app, pull-requests, typescript
- Language: TypeScript
- Homepage: https://github.com/apps/branch-switcher
- Size: 1.93 MB
- Stars: 17
- Watchers: 2
- Forks: 0
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# branch-switcher
[![Build Status](https://travis-ci.org/s4heid/branch-switcher.svg?branch=master)](https://travis-ci.org/s4heid/branch-switcher)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)A GitHub App built with [Probot](https://github.com/probot/probot) that automatically
updates the base ref of a pull request if it has been opened against a non-preferred
branch.## How it works
In projects where the default branch is not master, pull requests are often opened against a wrong branch. Typically, maintainers of the project need to reach out to the authors and ask them to change the base branch as most bigger projects have automated tests configured against the default branch.
The intent of this GitHub app is to support maintainers by automatically changing the base branch of pull requests to the default branch if applicable. The app listens to a set of [webhooks](https://developer.github.com/v3/activity/events/types/#pullrequestevent):
- `pull_request.opened`,
- `pull_request.reopened`,
- `pull_request.edited`,
- `pull_request.labeled`,
- `pull_request.unlabeled`,which triggers
- a check whether the base branch of the pull request matches the preferred branch and changes it if applicable,
- comments on the pull request and informs the author about the changes being made.![](assets/preview.png)
## Installation
1. [Install the GitHub App](https://github.com/apps/branch-switcher) for the intended repositories.
1. Create a `.github/branch-switcher.yml` file in the root of the intended repositories where
branch-switcher has been installed. This configuration file is optional and overrides any of the default
settings.## Configuration
The following properties are currently supported:
* `preferredBranch` *(string)* - name of the preferred branch against which the
pull request should be opened. Default: develop.
* `switchComment` *(string)* - content of the message indicating that the base
has been updated to the preferred branch. `{{author}}` can be used as a placeholder
which interpolates to the pull request author and `{{preferredBranch}}` analogously.
* `exclude` *(Array)* - list of all branches and labels that should be ignored.
By default, all branches are considered and no labels are excluded.
- `branch` *(string)* - name of the branch that should be ignored.
- `label` *(string)* - name of the label that should be ignored.**Example** `.github/branch-switcher.yml`:
```yaml
exclude:
- branch: do-nothing
- branch: dont-touch-*
- label: ignore-me
switchComment: >
Hey @{{author}}, the base branch of your pull request has been changed
to {{preferredBranch}}. Have a nice day! :wave:
```Above config does not touch the base branch if there is a label `ignore-me` attached
on the pull request and it also does not switch if the base branch is either called
`do-nothing` or every branch matching the wildcard `dont-touch-*`.## Development
1. Follow the [docs for deployment](https://probot.github.io/docs/deployment) and
set the following **Permissions & events** for the GitHub App:
- Pull requests - **Read & Write**
- [x] Check the box for **Pull request review comment** events
- Repository metadata - **Read-only**
- Single File - **Read-only**
- Path: `.github/branch-switcher.yml`
2. Clone the repo:
```sh
git clone [email protected]:s4heid/branch-switcher.git
```
3. Copy [.env.example](.env.example) to `.env` and set the right environment variables as described in the official [probot docs](https://probot.github.io/docs/configuration)
4. Install app dependencies and run the app:
```sh
# Install dependencies
npm install# Run typescript and run the bot
npm run build && npm start
```## Contributing
If you have suggestions for how branch-switcher could be improved, or want to report a bug, open an issue! We'd love all and any contributions.
For more, check out the [Contributing Guide](CONTRIBUTING.md).
## License
[Apache 2.0](LICENSE)