Skip to content

Commit

Permalink
Git flow driven travis docker builds (#111)
Browse files Browse the repository at this point in the history
* added gitflow things

* fix branch regexp

* fix phonies

* Update Makefile

* added TRAVIS_CURRENT_BRANCH

* fixed BRANCH ENV

* Update .travis.yml

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* try hack

* Update .travis.yml

* fix builds

* Update .travis.yml
  • Loading branch information
kamaev authored Aug 22, 2018
1 parent a78643a commit c0c6a85
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
20 changes: 17 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ before_script:
- gem install fpm
script:
- make packages
- make docker_image
before_deploy:
- echo "$DOCKER_PASSWORD" | docker login -u="$DOCKER_USERNAME" --password-stdin
deploy:
Expand All @@ -46,12 +45,27 @@ deploy:
on:
tags: true
- provider: script
script: make docker_push
script:
- make docker_feature_images GIT_BRANCH="${TRAVIS_BRANCH////-}"
skip_cleanup: true
on:
all_branches: true
condition: $TRAVIS_PULL_REQUEST == "false" && $TRAVIS_BRANCH =~ ^(feature|hotfix).*$
- provider: script
script:
- make docker_develop_images
skip_cleanup: true
on:
branch: develop
- provider: script
script:
- make docker_latest_images
skip_cleanup: true
on:
branch: master
- provider: script
script: make docker_push_release
script:
- make docker_release_images
skip_cleanup: true
on:
tags: true
28 changes: 21 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
GIT_BRANCH := "undefined"
GIT_HASH := $(shell git log --pretty=format:%H -n 1)
GIT_HASH_SHORT := $(shell ${GIT_HASH::6})
GIT_TAG := $(shell git describe --always --tags --abbrev=0 | tail -c+2)
GIT_COMMIT := $(shell git rev-list v${GIT_TAG}..HEAD --count)
GO_VERSION := $(shell go version | cut -d' ' -f3)
FEATURE_VERSION := ${GIT_TAG}-${GIT_BRANCH}
DEVELOP_VERSION := nightly-${GIT_HASH_SHORT}
VERSION := ${GIT_TAG}.${GIT_COMMIT}
VENDOR := "SKB Kontur"
URL := "https://github.com/moira-alert/moira"
Expand Down Expand Up @@ -120,20 +124,30 @@ deb: tar
.PHONY: packages
packages: clean build tar rpm deb

.PHONY: docker_image
docker_image:
.PHONY: docker_feature_images
docker_feature_images:
for service in "filter" "notifier" "api" "checker" ; do \
docker build --build-arg MoiraVersion=${VERSION} --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_COMMIT=${GIT_HASH} -f Dockerfile.$$service -t moira/$$service:${VERSION} -t moira/$$service:latest . ; \
docker build --build-arg MoiraVersion=${FEATURE_VERSION} --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_COMMIT=${GIT_HASH} -f Dockerfile.$$service -t moira/$$service:${FEATURE_VERSION} . ; \
docker push moira/$$service:${FEATURE_VERSION} ; \
done

.PHONY: docker_push
docker_push:
.PHONY: docker_develop_images
docker_develop_images:
for service in "filter" "notifier" "api" "checker" ; do \
docker build --build-arg MoiraVersion=${DEVELOP_VERSION} --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_COMMIT=${GIT_HASH} -f Dockerfile.$$service -t moira/$$service:${DEVELOP_VERSION} . ; \
docker push moira/$$service:${DEVELOP_VERSION} ; \
done

.PHONY: docker_latest_images
docker_latest_images:
for service in "filter" "notifier" "api" "checker" ; do \
docker build --build-arg MoiraVersion=${VERSION} --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_COMMIT=${GIT_HASH} -f Dockerfile.$$service -t moira/$$service:latest . ; \
docker push moira/$$service:latest ; \
done

.PHONY: docker_push_release
docker_push_release:
.PHONY: docker_release_images
docker_release_images:
for service in "filter" "notifier" "api" "checker" ; do \
docker build --build-arg MoiraVersion=${VERSION} --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_COMMIT=${GIT_HASH} -f Dockerfile.$$service -t moira/$$service:${VERSION} . ; \
docker push moira/$$service:${VERSION} ; \
done

0 comments on commit c0c6a85

Please sign in to comment.