---
language: go

go:
  - '1.13.x'

go_import_path: github.com/brancz/kube-rbac-proxy

env:
  - GO111MODULE=on

cache:
  directories:
  - $GOCACHE
  - $GOPATH/pkg/mod

services:
  - docker

jobs:
  include:
    - name: Integration Tests
      stage: test
      before_script:
        - curl -Lo kind https://github.com/kubernetes-sigs/kind/releases/download/v0.7.0/kind-linux-amd64 && chmod +x kind && sudo mv kind /usr/local/bin/
        - kind create cluster --config test/e2e/kind-config/kind-config.yaml
      script:
        - VERSION=local make container
        - kind load docker-image quay.io/brancz/kube-rbac-proxy:local
        - make test-e2e
    - name: Push container images
      stage: push-docker-image
      script:
        - "sudo chmod o+x /etc/docker"
        - "echo ${QUAY_PASSWORD} | docker login -u ${QUAY_USERNAME} --password-stdin quay.io"
        - '[ "$TRAVIS_BRANCH" = "master" ] && VERSION="$(git rev-parse --abbrev-ref HEAD | tr / -)-$(date +%Y-%m-%d)-$(git rev-parse --short HEAD)" make push || :'
        - '[ -n "$TRAVIS_TAG" ] && VERSION=$TRAVIS_TAG make push || :'

stages:
  - name: test
  - name: push-docker-image
    if: (type != pull_request)
