language: go
go:
  - "1.14.7"

env:
  global:
    # Sanitize git branch name into a valid docker tag name
    - IMAGE_TAG_NAME=$(echo -n $TRAVIS_BRANCH | tr -c "[a-zA-Z0-9._'" "_")
    - GO111MODULE=on

services:
  - docker

script:
  - scripts/test-infra/verify.sh
  - scripts/test-infra/build-image.sh
  - if [ "$TRAVIS_BRANCH" == master -a -n "$IMAGE_REPO_USER" ]; then
      set -e;
      echo "$IMAGE_REPO_PASSWORD" | docker login -u "$IMAGE_REPO_USER" --password-stdin quay.io;
      make push -e;
      scripts/test-infra/test-e2e.sh;
    fi

deploy:
  - on:
      branch: master
      condition: -n "$IMAGE_REPO_USER"
    provider: script
    script: echo "$IMAGE_REPO_PASSWORD" | docker login -u "$IMAGE_REPO_USER" --password-stdin quay.io && make push -e
  - on:
      tags: true
      condition: -n "$IMAGE_REPO_USER"
    provider: script
    script: echo "$IMAGE_REPO_PASSWORD" | docker login -u "$IMAGE_REPO_USER" --password-stdin quay.io && make push -e