Cascading branch sync
Our team often works on multiple releases at once and we often wasted time on keeping future releases in sync. For example, one team member pushed features planned for release/1.1.0
and other team member added changes for future release/1.2.0
, we would want to merge changes from release/1.1.0
into release/1.2.0
. This script will do this automatically.
Branch sequence is fully customizable and supports regex expressions, which are alphabetically sorted by default, but this can be changed to semver sort (for example, release/1.1.0
is before release/1.2.0
).
Note 1: nodegit
requires C compiler, check nodegit Getting started on how to configure it, if installation fails.
Note 2: installing using yarn
will most likely fail when installing nodegit
- clone the repo and install dependencies using
npm install
- create files
.env
andsync-config.yml
, ensure git is configured to be able to clone without prompt - use
npm start
to run the server - configure GitHub repository webhooks and point it to server (make sure to use public IP)
GITHUB_WEBHOOK_SECRET
: a secred shared with GitHub's webhook configGITHUB_TOKEN
: github token which authorizes at least repo permissionsSYNC_AT_START
: set totrue
if script should add all branch pairs to sync job on startMAILGUN_API_KEY
: Mailgun API keyMAILGUN_DOMAIN
: Mailgun domain nameMAIL_SEND_FROM
: e-mail address to use as mail "from" addressMAIL_SEND_TO
: e-mail address(es) to send mail to, for multiple addresses, separate each address with,
git_config
:name: value
pairs of git config to set for all repositories (e.g.user.name: username
)repositories
: list of repositories to handle, each should contain the following properties:remote_url
: URL where repository is hostedlocal_path
: path where the repository will be cloned to, either absolute or relative to project rootbranches
: list of branches to match for syncing, each can be either a plain string (exact match) or an object, which can specify:regex
: regex used to match branchessort
(optional): if set tosemver
,semverSort.asc
will be used, otherwise defaults to alphabetical sort
The script will merge first matching branch into the next one, unless the matched branch is last on the list. To chain merges, it relies on script creating a push event for next branch in sequence.
- Go to repository -> Settings -> Webhooks
- Click Add webhook and set:
- Payload url:
[url to this webook server]/github/callback
(don't forget about using the correct port in the url) - Content type: application/json
- Secret: the same secret as
GITHUB_WEBHOOK_SECRET
value in.env
- Events: can be anything, but currently just the
push
events are processed, so it's suggested to use "Just thepush
event" for best performance
- Payload url:
Use npm test
to run linter and tests or npm run test:coverage
to see coverage.
For watch mode (re-run tests when code changes), use npm run test:watch
.