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

Add Container Build Step to CI #113

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
22 changes: 21 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ on:
- ".github/workflows/bot.yaml"
- ".github/workflows/todo-issue.yaml"

jobs:
env:
COPILOT_OPS_IMG: "quay.io/copilot-ops/copilot-ops"
COPILOT_OPS_IMG_TAG: "latest"

jobs:
test:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -77,3 +80,20 @@ jobs:
with:
name: copilot-ops-darwin-arm64
path: copilot-ops-darwin-arm64

build-image:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout Source
uses: actions/checkout@v3
- name: Build Container Image
run: IMG="${COPILOT_OPS_IMG}"; IMG_TAG="${COPILOT_OPS_IMG_TAG}"; make docker-build
- name: Export Container Image
run: docker save -o /tmp/image.tar "${COPILOT_OPS_IMG}:${COPILOT_OPS_IMG_TAG}"
- name: Save Container Image as Artifact
uses: actions/upload-artifact@v3
with:
name: copilot-ops-image
path: /tmp/image.tar

47 changes: 31 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
build:
##@ General

IMG ?= quay.io/copilot-ops/copilot-ops
IMG_TAG ?= latest

# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk commands is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php

.PHONY: help
help: ## Display this help.
@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)

##@ Build

build: ## Build the copilot-ops file.
@ echo ▶️ go build
go build
@ echo ✅ go build
@ echo ./copilot-ops -h "# run me!"
.PHONY: build

image:
docker build -t quay.io/copilot-ops/copilot-ops .
@ echo ✅ docker build
.PHONY: image
image: ## Build a container image of the current project.
docker build -t ${IMG}:${IMG_TAG} .
@ echo ✅ docker build

publish: image
docker push quay.io/copilot-ops/copilot-ops
@ echo ✅ docker push
.PHONY: publish
publish: image ## Publish the container image into Quay.io.
docker push ${IMG}:${IMG_TAG}
@ echo ✅ docker push

##@ Development

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

##@ Build Dependencies

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

##@ Download utilities

# for performing lints
.PHONY: golangci-lint
.PHONY: golangci-lint
GOLANGCILINT := $(LOCALBIN)/golangci-lint
GOLANGCI_URL := https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh
golangci-lint: $(GOLANGCILINT) ## Download golangci-lint
Expand All @@ -58,6 +72,7 @@ $(GINKGO): $(LOCALBIN)


##@ Build Dependencies

LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
@ echo "▶️ Local binary directory not present, creating..."
Expand Down