now-travis
now-travis copied to clipboard
Getting production deployments in pull requests
@eliperelman
Trying out this package, I've noticed that for Pull Requests I get the production and staging status updates. This is problematic as PR changes are now getting pushed to production pre merging.
Here is an example PR: https://github.com/pure-css/pure-site/pull/390
Here is my travis config:
after_script:
- NOW_ALIAS=purecss.io ./node_modules/.bin/now-travis;
or https://github.com/pure-css/pure-site/blob/master/.travis.yml#L8
Am I doing something wrong?

@redonkulus I ran into the same issue. I solved it by prepending a bash test to the script:
after_success:
- test $TRAVIS_EVENT_TYPE = "pull_request" && now-travis
And since I do want aliasing on pushes to master, I added a separate line for that one:
after_success:
- test $TRAVIS_EVENT_TYPE = "pull_request" && now-travis
- test $TRAVIS_EVENT_TYPE = "push" && test $TRAVIS_BRANCH = "master" && now-travis && now alias --token=$NOW_TOKEN
Note that now-travis
doesn't do the aliasing in that last line, as I couldn't get that to work. But the Now CLI command works just fine too.
I now use
branches:
only:
- master
and build stages like this:
jobs:
fast_finish: true
include:
# ...
- stage: deploy
script:
- NOW_ALIAS=xyz.now.sh node_modules/.bin/now-travis
stages:
# ...
- name: deploy
if: branch = master