Reputation: 25240
My Travis file contains two stages:
test
, which runs build/test for multiple Node.js versions (and works)deploy
, which should run build and deploy the code to npm when the following condition is met: branch = master AND tag IS present AND type = push
I pushed a tagged commit to the master (so all three conditions should be met), but after the test
stage finishes successfully, the deploy
stage is not started.
Here are other (potentially important) parts of my .travis.yml
file:
language: node_js
node_js:
- '8'
- '9'
- '10'
#- '11' # Runs the coverage report (added below)
before_script: npm run build
script:
- npm run lint
- npm run coverage
jobs:
include:
- stage: test
node_js: '11'
after_success: 'cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js'
- stage: deploy
node_js: '11'
script: skip
deploy:
provider: npm
# ...
stages:
- test
- name: deploy
if: branch = master AND tag IS present AND type = push
Upvotes: 1
Views: 1446
Reputation: 25240
I found it out myself after adding these lines to my travis file:
echo "$TRAVIS_EVENT_TYPE" # result: push
echo "$TRAVIS_TAG" # result: v0.14.0
echo "$TRAVIS_BRANCH" # result: v0.14.0
So the branch is set to the tag name, when a tag is set. I also found this hint on the docs for environment variables:
Note that for tags, git does not store the branch from which a commit was tagged.
Strangely, you can still check for the branch in the deploy condition. So this worked for me:
# ...
deploy:
provider: npm
# ...
on:
tags: true
branch: master
stages:
- test
- name: deploy
if: type = push
Upvotes: 1