travis: run deploy as final stage

The `deploy:` section is executed as part of each successful job. That
means the container images and Helm charts are built and pushed many
times during testing after a push/merge event.

By creating a deploy stage and listing it after the tests, it is
guaranteed to run only once after all tests have succeeded. By adding a
condition to only run the stage for push events, the images and Helm
charts should only get built+pushed after a PR has been merged.

See-also: https://docs.travis-ci.com/user/conditional-builds-stages-jobs#Specifying-conditions
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-04-28 11:50:03 +02:00 committed by mergify[bot]
parent c8df7aa475
commit b6ea4ecdf0

View File

@ -51,12 +51,17 @@ before_script:
# only the arm64 fallback repo is unsigned and needs --allow-unauthenticated
- sudo apt-get -y --allow-unauthenticated install librados-dev librbd-dev
# Two stages for testing, each stage runs its jobs in parallel, but stages are
# run after each other, unless the last stage fails.
# Only run the deploy stage on push (not pull_request) events.
stages:
- build testing
- e2e testing
- name: deploy
if: type = push
jobs:
include:
# two stages for testing, each stage runs its jobs in parallel, but stages
# are run after each other, unless the last stage fails
# - build testing
# - e2e testing
- stage: build testing
name: static-check-make
install:
@ -132,8 +137,6 @@ jobs:
- make image-cephcsi || travis_terminate 1;
- scripts/travis-helmtest.sh v1.17.0 || travis_terminate 1;
deploy:
- provider: script
on: # yamllint disable-line rule:truthy
all_branches: true
script: ./deploy.sh
- stage: deploy
name: push artifacts to repositories
script: ./deploy.sh