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
npm install
.env
and sync-config.yml
, ensure git is configured to be able to clone without promptnpm start
to run the serverGITHUB_WEBHOOK_SECRET
: a secred shared with GitHub's webhook configGITHUB_TOKEN
: github token which authorizes at least repo permissionsSYNC_AT_START
: set to true
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 to semver
, semverSort.asc
will be used, otherwise defaults to alphabetical sortThe 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.
[url to this webook server]/github/callback
(don't forget about using the correct port in the url)GITHUB_WEBHOOK_SECRET
value in .env
push
events are processed, so it's suggested to use "Just the push
event" for best performanceUse 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
.