I have a Travis repo enabled for pull requests. When a pull request is opened, the travis.yml triggers both the tests and the deploy
script.
I would like opened pull requests to run all tests, but not run the deploy script unless merged.
Below is a sample of my travis.yml
:
sudo: true
language: node_js
before_deploy:
- wget https://s3.amazonaws.com/go-cli/releases/v6.12.4/cf-cli_amd64.deb -qO temp.deb && sudo dpkg -i temp.deb
- rm temp.deb
- cf login
- cf install-plugin autopilot -r CF-Community
- npm run build
deploy:
- edge: true
provider: script
script: cf zero-downtime-push app-name -f ./manifest.yml
on:
branch: master
You can use travis special environment variable
TRAVIS_PULL_REQUEST
to detect if build is triggered for PR.So your script can look like:
More travis varibles you can faund on:
https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables