Skip to content

Commit 52944f0

Browse files
committed
add container build step to actions
Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>
1 parent 4bbfe58 commit 52944f0

File tree

2 files changed

+52
-17
lines changed

2 files changed

+52
-17
lines changed

.github/workflows/ci.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ on:
2020
- ".github/workflows/bot.yaml"
2121
- ".github/workflows/todo-issue.yaml"
2222

23-
jobs:
23+
env:
24+
COPILOT_OPS_IMG: "quay.io/copilot-ops/copilot-ops"
25+
COPILOT_OPS_IMG_TAG: "latest"
2426

27+
jobs:
2528
test:
2629
runs-on: ubuntu-latest
2730
steps:
@@ -77,3 +80,20 @@ jobs:
7780
with:
7881
name: copilot-ops-darwin-arm64
7982
path: copilot-ops-darwin-arm64
83+
84+
build-image:
85+
runs-on: ubuntu-latest
86+
needs: test
87+
steps:
88+
- name: Checkout Source
89+
uses: actions/checkout@v3
90+
- name: Build Container Image
91+
run: IMG="${COPILOT_OPS_IMG}"; IMG_TAG="${COPILOT_OPS_IMG_TAG}"; make docker-build
92+
- name: Export Container Image
93+
run: docker save -o /tmp/image.tar "${COPILOT_OPS_IMG}:${COPILOT_OPS_IMG_TAG}"
94+
- name: Save Container Image as Artifact
95+
uses: actions/upload-artifact@v3
96+
with:
97+
name: copilot-ops-image
98+
path: /tmp/image.tar
99+

Makefile

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,41 @@
1-
build:
1+
##@ General
2+
3+
IMG ?= quay.io/copilot-ops/copilot-ops
4+
IMG_TAG ?= latest
5+
6+
# The help target prints out all targets with their descriptions organized
7+
# beneath their categories. The categories are represented by '##@' and the
8+
# target descriptions by '##'. The awk commands is responsible for reading the
9+
# entire set of makefiles included in this invocation, looking for lines of the
10+
# file as xyz: ## something, and then pretty-format the target and help. Then,
11+
# if there's a line with ##@ something, that gets pretty-printed as a category.
12+
# More info on the usage of ANSI control characters for terminal formatting:
13+
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
14+
# More info on the awk command:
15+
# http://linuxcommand.org/lc3_adv_awk.php
16+
17+
.PHONY: help
18+
help: ## Display this help.
19+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
20+
21+
##@ Build
22+
23+
build: ## Build the copilot-ops file.
224
@ echo ▶️ go build
325
go build
426
@ echo ✅ go build
527
@ echo ./copilot-ops -h "# run me!"
628
.PHONY: build
729

8-
image:
9-
docker build -t quay.io/copilot-ops/copilot-ops .
10-
@ echo ✅ docker build
1130
.PHONY: image
31+
image: ## Build a container image of the current project.
32+
docker build -t ${IMG}:${IMG_TAG} .
33+
@ echo ✅ docker build
1234

13-
publish: image
14-
docker push quay.io/copilot-ops/copilot-ops
15-
@ echo ✅ docker push
1635
.PHONY: publish
36+
publish: image ## Publish the container image into Quay.io.
37+
docker push ${IMG}:${IMG_TAG}
38+
@ echo ✅ docker push
1739

1840
##@ Development
1941

@@ -29,17 +51,9 @@ test: lint ginkgo ## Run tests.
2951
$(GINKGO) --coverprofile "cover.out" ./...
3052
@ echo "✅ ginkgo test"
3153

32-
##@ Build Dependencies
33-
34-
## Location to install dependencies to
35-
LOCALBIN ?= $(shell pwd)/bin
36-
$(LOCALBIN):
37-
mkdir -p $(LOCALBIN)
38-
3954
##@ Download utilities
4055

41-
# for performing lints
42-
.PHONY: golangci-lint
56+
.PHONY: golangci-lint
4357
GOLANGCILINT := $(LOCALBIN)/golangci-lint
4458
GOLANGCI_URL := https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh
4559
golangci-lint: $(GOLANGCILINT) ## Download golangci-lint
@@ -58,6 +72,7 @@ $(GINKGO): $(LOCALBIN)
5872

5973

6074
##@ Build Dependencies
75+
6176
LOCALBIN ?= $(shell pwd)/bin
6277
$(LOCALBIN):
6378
@ echo "▶️ Local binary directory not present, creating..."

0 commit comments

Comments
 (0)