Skip to content

Instantly share code, notes, and snippets.

@lxhunter
Created October 8, 2016 09:30
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save lxhunter/758e1e3041d7ec7aec3814018d781e29 to your computer and use it in GitHub Desktop.
Save lxhunter/758e1e3041d7ec7aec3814018d781e29 to your computer and use it in GitHub Desktop.
Automated merging of branches into master for travis-ci or any other ci
#!/bin/bash
git config --global user.email 'travis@travis-ci.org'
git config --global user.name 'Travis'
git remote set-branches --add origin master
git fetch
git reset --hard
git checkout master
git merge --ff-only "$TRAVIS_COMMIT"
git push git+ssh://git@github.com/${TRAVIS_REPO_SLUG}.git master
@lxhunter
Copy link
Author

lxhunter commented Oct 8, 2016

For automerge you need to use credentials to let travis access the repos, I used:

# must be already activated and synced in travis
cd git-repo/
travis sshkey --upload path/to/key

If you have no key, you can start like this:

travis sshkey --generate

If you just want to merge one branch into master use (you might want to fork my scripts):

language: python
cache: pip
sudo: required
script:
- echo "yes!"
branches:
  only:
  - next
after_success:
- curl https://gist.githubusercontent.com/lxhunter/758e1e3041d7ec7aec3814018d781e29/raw/merge.sh | bash
# optional automatic versioning
- curl https://gist.githubusercontent.com/lxhunter/9d4310462b6972a3f57b5f914543fd51/raw/semver.sh | bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment