Skip to content

Commit

Permalink
Only push to Dockerhub when a tag
Browse files Browse the repository at this point in the history
  • Loading branch information
battlecow committed Nov 30, 2018
1 parent f89311b commit d027120
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ DOCKER_IMAGE_BASE := jamfdevops
DOCKER_ORG :=
DOCKER_IMAGE := jamfpro

IS_TAG=$(shell git describe --exact-match; echo $$?)
VERSION=$(shell git --no-pager describe --tags --always)
SHA=$(shell git rev-parse --verify HEAD)
BUILD_URL=$(TRAVIS_JOB_WEB_URL)
Expand Down Expand Up @@ -39,8 +40,12 @@ publish-latest: tag-latest ## Publish the `latest` taged container
docker push $(DOCKER_IMAGE_BASE)$(DOCKER_ORG)/$(DOCKER_IMAGE):latest

publish-version: tag-version ## Publish the `{version}` tagged container
@echo 'Publish $(VERSION) to $(DOCKER_IMAGE_BASE)$(DOCKER_ORG)'
docker push $(DOCKER_IMAGE_BASE)$(DOCKER_ORG)/$(DOCKER_IMAGE):$(VERSION)
@if [ "$(IS_TAG)" = "0" ]; then\
echo 'Publish $(VERSION) to $(DOCKER_IMAGE_BASE)$(DOCKER_ORG)';\
docker push $(DOCKER_IMAGE_BASE)$(DOCKER_ORG)/$(DOCKER_IMAGE):$(VERSION);\
else \
echo 'Not a git tag, skipping push step';\
fi

# Docker tagging
tag: tag-latest tag-version ## Generate image tags for the `{version}` and `latest`
Expand All @@ -59,3 +64,8 @@ repo-login: ## Login to docker repo

version: ## Output the current version
@echo $(VERSION)

testit:
if [ "$(IS_TAG)" = "0" ]; then\
echo "Hello world";\
fi

0 comments on commit d027120

Please sign in to comment.