language: go
sudo: required

go:
  - "1.10"
env:
  global:
  - PATH=$GOROOT/bin:$GOPATH/bin:$PATH

script:
  - make lint
  - sudo -E env "PATH=$PATH" make test
  - make build
  - make image

before_deploy:
  - docker login -u "$REGISTRY_USER" -p "$REGISTRY_PASS"

deploy:
  # Push image to Dockerhub on merge to master
  - provider: script
    skip_cleanup: true
    script: docker push nfvpe/sriov-cni:release-v2
    on:
      branch: master
  # Push image to Dockerhub on tag
  - provider: script
    skip_cleanup: true
    script: >
      bash -c '
      docker tag nfvpe/sriov-cni nfvpe/sriov-cni:$TRAVIS_TAG;
      docker push nfvpe/sriov-cni:$TRAVIS_TAG;
      echo foo'
    on:
      tags: true
      all_branches: true
      condition: "$TRAVIS_TAG =~ ^v[0-9].*$"
