From deecf6265fa93f57c2ec607ef92d803e9932a885 Mon Sep 17 00:00:00 2001 From: Yoav Rotem Date: Thu, 1 Oct 2020 18:37:38 +0300 Subject: [PATCH] Test Travis build condition (#713) * Add condition to make docker Build and push Docker image only when pushing to master. * Update to Golang 1.15 As https://github.com/aquasecurity/kube-bench/pull/706 did, just doing it in my fork to test Travis changes about the build --- .travis.yml | 10 ++++++++-- Dockerfile | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 676f5b5..d05adcb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,10 @@ before_install: - pip install --user yamllint==1.18.0 - gem install --no-document fpm - go get -t -v ./... - - echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin + - | + if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then + echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin + fi script: - yamllint -c ./.yamllint.yaml . @@ -28,7 +31,10 @@ script: - test -d cfg - test -f kube-bench # Build and push the multi-arch Docker image - - make docker + - | + if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then + make docker + fi after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/Dockerfile b/Dockerfile index 1ce9da2..2331b39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.14.0 AS build +FROM golang:1.15.0 AS build WORKDIR /go/src/github.com/aquasecurity/kube-bench/ COPY go.mod go.sum ./ COPY main.go .