Script for Travis and Git Pushes

I'm looking to create a script for Travis that, when a push is made to a branch in my github repo, it checks the name of the branch that the push is made to, and if it is the master branch the updates get deployed to /var/www/html on my webserver. If the name of the branch is not master the updates get pushed to /var/www/test, again on my webserver.

The reason I'm looking to do this is that the /test virtual host is password protected so updates can be viewed by only the web developers, the updates can then be tested before the branch is merged with the master branch and the update is live.

I've set Travis up correctly and it makes build like it should I just need help with creating a script that does the above job and updating the .travis.yml file to reflect this.