-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (41 loc) · 1.35 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
SHELL := bash
VERSION_VALUE ?= $(shell git rev-parse --short HEAD 2>/dev/null)
DOCKER_IMAGE_REPO ?= sbom
DOCKER_DEST ?= $(DOCKER_IMAGE_REPO):$(VERSION_VALUE)
GCR ?= us-east4-docker.pkg.dev/travis-ci-prod-services-1/travis
GCR_IMAGE ?= $(GCR)/$(DOCKER_IMAGE_REPO)
ifdef $$GCR_ACCOUNT_JSON_ENC
GCR_ACCOUNT_JSON_ENC := $$GCR_ACCOUNT_JSON_ENC
endif
ifndef $$TRAVIS_BRANCH
TRAVIS_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
endif
ifneq ($(TRAVIS_BRANCH),master)
BRANCH := $(shell echo "$(TRAVIS_BRANCH)" | sed 's/\//_/')
VERSION_VALUE := $(VERSION_VALUE)-$(BRANCH)
endif
ifdef $$TRAVIS_PULL_REQUEST
TRAVIS_PULL_REQUEST := $$TRAVIS_PULL_REQUEST
endif
DOCKER ?= docker
.PHONY: docker-build
docker-build:
$(DOCKER) build -t $(DOCKER_DEST) .
.PHONY: docker-push
docker-push:
$(shell echo ${GCR_ACCOUNT_JSON_ENC} | openssl enc -d -base64 -A > ./gce-account.json)
cat ./gce-account.json | $(DOCKER) login -u _json_key --password-stdin https://us-east4-docker.pkg.dev
#rm -f ./gce-account.json
$(DOCKER) tag $(DOCKER_DEST) $(GCR_IMAGE):$(VERSION_VALUE)
$(DOCKER) push $(GCR_IMAGE):$(VERSION_VALUE)
.PHONY: docker-latest
docker-latest:
$(DOCKER) tag $(DOCKER_DEST) $(QUAY_IMAGE):latest
$(DOCKER) push $(QUAY_IMAGE):latest
.PHONY: ship
ship: docker-build docker-push
ifeq ($(TRAVIS_BRANCH),master)
ifeq ($(TRAVIS_PULL_REQUEST),false)
ship: docker-latest
endif
endif