Skip to content

Instantly share code, notes, and snippets.

@lxhunter
Created October 8, 2016 09:30
Show Gist options
  • 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 '[email protected]'
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://[email protected]/${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