language: go

matrix:
  include:
  - name: amd64
    os: linux
    env: ARCH=amd64
  # - name: ppc64le
  #   os: linux-ppc64le
  #   env: 
  #     - ARCH=ppc64le
  #     - DOCKERFILE=images/Dockerfile.ppc64le

before_install:
  - sudo apt-get update -qq
  - sudo systemctl restart docker

script:
  - make test
  - make build
  - make
  - make image TAG="$REGISTRY_USER/sriov-device-plugin"

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

deploy:
  # Push image to Dockerhub on merge to master
  - provider: script
    skip_cleanup: true
    script: >
      bash -c '
      if [[ "${ARCH}" == "amd64" ]]; then docker push $REGISTRY_USER/sriov-device-plugin; fi;
      docker tag $REGISTRY_USER/sriov-device-plugin $REGISTRY_USER/sriov-device-plugin:$ARCH;
      docker push $REGISTRY_USER/sriov-device-plugin:$ARCH;
      echo done'
    on:
      branch: master
  # Push image to Dockerhub on tag
  - provider: script
    skip_cleanup: true
    script: >
      bash -c '
      if [[ "${ARCH}" == "amd64" ]]; then docker tag $REGISTRY_USER/sriov-device-plugin $REGISTRY_USER/sriov-device-plugin:"$TRAVIS_TAG"; docker push $REGISTRY_USER/sriov-device-plugin:"$TRAVIS_TAG"; fi;
      docker tag $REGISTRY_USER/sriov-device-plugin $REGISTRY_USER/sriov-device-plugin:"$TRAVIS_TAG-$ARCH";
      docker push $REGISTRY_USER/sriov-device-plugin:"$TRAVIS_TAG-$ARCH";
      echo done'
    on:
      tags: true
      all_branches: true
      condition: "$TRAVIS_TAG =~ ^v[0-9].*$"
