Skip to content

Commit

Permalink
adding docker build to actions
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy J. Miller <jeremymv2@users.noreply.github.com>
  • Loading branch information
jeremymv2 committed Sep 21, 2023
1 parent 8d64d54 commit 8e11d52
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 12 deletions.
34 changes: 26 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: 'directory listing'
run: ls -l
- name: 'cat cmd/package.json'
run: cat cmd/package.json
- name: Bump Application version in package.json
if: needs.detect_changes.outputs.bump_app == 'true'
id: app-version-bump
Expand All @@ -59,9 +55,31 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
PACKAGEJSON_DIR: 'cmd'
- name: 'cat cmd/package.json'
run: cat cmd/package.json
- name: 'Output Step'
- name: New Version Output
env:
NEW_TAG: ${{ steps.app-version-bump.outputs.newTag }}
run: echo "new tag $NEW_TAG"
run: echo "New version $NEW_TAG"
- name: Retrieve Docker Image Name with Tag
run: |
echo "IMG_TAG_NAME=$(make docker_img_name_with_tag)" >> $GITHUB_OUTPUT
id: img_name_and_version_tag
- name: New Image Name with Tag
env:
IMG_TAG_NAME: ${{ steps.img_name_and_version_tag.outputs.IMG_TAG_NAME }}
run: |
echo "New Image Name with Tag: $IMG_TAG_NAME"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: ${{ steps.img_name_and_version_tag.outputs.IMG_TAG_NAME }}
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
VERSION = $(shell jq -r '.version' <cmd/package.json)
REGISTRY ?= jmv2
TAG ?= ${VERSION}
IMGNAME ?= site-deploy-controller
IMAGE = $(REGISTRY)/$(IMGNAME)
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.27.1

Expand Down Expand Up @@ -82,8 +85,9 @@ run: manifests generate fmt vet ## Run a controller from your host.
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
$(CONTAINER_TOOL) build -t ${IMG} .
docker-build: test lint ## Build docker image with the manager.
$(CONTAINER_TOOL) image inspect ${IMAGE}:${TAG} >/dev/null 2>&1 || \
$(CONTAINER_TOOL) build -t ${IMAGE}:${TAG} .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
Expand Down Expand Up @@ -165,3 +169,11 @@ $(CONTROLLER_GEN): $(LOCALBIN)
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

.PHONY: version
version:
@echo "Version is: $(VERSION)"

.PHONY: docker_img_name_with_tag
docker_img_name_with_tag:
@echo "$(IMAGE):$(VERSION)"

0 comments on commit 8e11d52

Please sign in to comment.