Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): specific build branch name under travis #20

Merged
merged 1 commit into from
Dec 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ services:
- docker
script:
- make _output/bin/kubectl-trace
after_success:
- ./hack/release-image.sh
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ DOCKER ?= docker

COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true)
GIT_COMMIT := $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO})
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")


IMAGE_BPFTRACE_BRANCH := quay.io/fntlnz/kubectl-trace-bpftrace:$(GIT_BRANCH_CLEAN)
IMAGE_BPFTRACE_COMMIT := quay.io/fntlnz/kubectl-trace-bpftrace:$(GIT_COMMIT)
IMAGE_BPFTRACE_LATEST := quay.io/fntlnz/kubectl-trace-bpftrace:latest
Expand Down
16 changes: 10 additions & 6 deletions hack/release-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ set -xeo pipefail
make=$(command -v make)
docker=$(command -v docker)

$make image/build
makeopts=""
if [[ ! -z "$TRAVIS_PULL_REQUEST_BRANCH" ]]; then
makeopts="-e GIT_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH image/build"
fi

$make $makeopts image/build

if [[ ! -z "$QUAY_TOKEN" ]]; then
$docker login -u="fntlnz+travisci" -p="$QUAY_TOKEN" quay.io
$make image/push

if [[ "$TRAVIS_BRANCH" = "master" ]]; then
$make image/latest
fi
$make $makeopts image/push
fi

if [[ "$TRAVIS_BRANCH" = "master" && "$TRAVIS_PULL_REQUEST_BRANCH" = "" ]]; then
$make $makeopts image/latest
fi