now-travis icon indicating copy to clipboard operation
now-travis copied to clipboard

Getting production deployments in pull requests

Open redonkulus opened this issue 7 years ago • 3 comments

@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 avatar Jan 21 '18 04:01 redonkulus

screen shot 2018-01-20 at 9 05 32 pm

redonkulus avatar Jan 21 '18 05:01 redonkulus

@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.

jbmoelker avatar Mar 20 '18 06:03 jbmoelker

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

swissspidy avatar Mar 23 '18 14:03 swissspidy