sudo: required

language: go
go:
  - "1.13.x"

services:
      - docker

addons:
  apt:
    packages:
      - docker-ce

before_install:

script:
    - ./build.sh
    - ./contrib/ci.sh

after_success:
    - if [ -z $DOCKER_NS ] ; then
        export DOCKER_NS=openfaas;
        fi

    - if [ ! -z "$TRAVIS_TAG" ] ; then
        export DOCKER_CLI_EXPERIMENTAL=enabled

        export REGISTRY=docker.io;
        ./ci/registryLogin.sh $REGISTRY; 
        ./ci/tagAndPush.sh "$REGISTRY" "$DOCKER_NS/gateway";
        ./ci/tagAndPush.sh "$REGISTRY" "$DOCKER_NS/basic-auth-plugin";

        export REGISTRY=quay.io;
        ./ci/registryLogin.sh $REGISTRY;
        ./ci/tagAndPush.sh "$REGISTRY" "$DOCKER_NS/gateway";
        ./ci/tagAndPush.sh "$REGISTRY" "$DOCKER_NS/basic-auth-plugin";

        fi
