kausar
kausar

Reputation: 71

Travis CI build triggered twice

I am using the following config.

before_install:
  - "sudo apt-get update"
  - "sudo apt-get install --no-install-recommends texlive-full"
script:
  - pdflatex file.tex
deploy:
  provider: releases
  file:
    - file.pdf
  api_key:
    secure: "MY_API_KEY"
  skip_cleanup: true

When I do git push origin master --tags, it creates two builds in Travis. One for master branch and the other for the tag. I want to only build and deploy when a tag is present. So I added the condition in line 1 as follows:

if: tag IS present
before_install:
  - "sudo apt-get update"
  - "sudo apt-get install --no-install-recommends texlive-full"
script:
  - pdflatex file.tex
deploy:
  provider: releases
  file:
    - file.pdf
  api_key:
    secure: "MY_API_KEY"
  skip_cleanup: true

But now then it builds fine and only when the tag is present but it does not deploy. Gives the following warning:

Skipping a deployment with the releases provider because this branch is not permitted

Upvotes: 1

Views: 545

Answers (1)

Azeem
Azeem

Reputation: 14587

You need to add tags: true under on in deploy section to trigger the deployment on tagging.

Here's an example of .travis.yml that triggers the deployment on tagging:

deploy:
  provider: ...
  api_key:  ...
  on:
    tags:   true

You may also trigger deployment by specifying the branch or branches in $TRAVIS_BRANCH (See documentation).

Upvotes: 2

Related Questions