I've trying to do a setup, where I use Travis CI (http://www.travis-ci.org) to build and test my program each time I commit to GitHub. My GitHub setup is to have a master and a slave/test branch, which I commit to before merging into master. However, as of right now I'm doing the merging manually on GitHub.com, which I could like to automate, such that when a build is successful on Travis, I want to merge my slave/test branch into the master right away. Does anybody know how this is possible on Travis CI or another way of achieving this with Travis?
1 Answer
You can prepare script which will use for merge your branches. Travis set some useful environment variables which you can use in your script.
Merge script can look like:
if [ "$TRAVIS_BRANCH" != "test" ]; then
exit 0;
fi
export GIT_COMMITTER_EMAIL=...
export GIT_COMMITTER_NAME=...
git checkout master || exit
git merge "$TRAVIS_COMMIT" || exit
git push ... # here need some authorization and url
Next you can put in .travis.yml
after_success: ./merge_script.sh
More info:
-
3in my experience, commands like
git checkout some-branch
will fail in Travis-CI. May 18, 2017 at 17:55