Skip to content

Commit

Permalink
Added Reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-pickin-epi committed Jul 3, 2024
1 parent 5170944 commit 135a567
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 9 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Build & Publish Docker Image"
on:
workflow_dispatch: {}
push: {}

jobs:
publish:
uses: "epimorphics/github-workflows/.github/workflows/publish.yml@reusable"
secrets:
# Repostory specific
aws_access_key_id: "${{ secrets.BUILD_LDS_AWS_ACCESS_KEY_ID }}"
aws_secret_access_key: "${{ secrets.BUILD_LDS_AWS_SECRET_ACCESS_KEY }}"
# Fixed
epi_gpr_access_token: "${{ secrets.EPI_GPR_READ_ACCESS_TOKEN }}"
62 changes: 53 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,55 @@
# build and push docker image to LDS ECR repository
# Override verisons by setting variables (environment or make command line):
# REGISTRY_VERSION (default 2.3.15)
.PHONY: clean image publish tag test vars

REGISTRY_VERSION?=2.3.15
IMAGE?=epimorphics/env-registry
VERSION?=2.3.15

.PHONY: build
build:
docker build --build-arg REGISTRY_VERSION=$(REGISTRY_VERSION) -t "$(IMAGE):latest" .
docker tag "$(IMAGE):latest" "$(IMAGE):$(REGISTRY_VERSION)"

ACCOUNT?=$(shell aws sts get-caller-identity | jq -r .Account)
AWS_REGION?=eu-west-1
ECR?=${ACCOUNT}.dkr.ecr.eu-west-1.amazonaws.com
NAME?=$(shell awk -F: '$$1=="name" {print $$2}' deployment.yaml | sed -e 's/[[:blank:]]//g')
SHORTNAME?=$(shell echo ${NAME} | cut -f2 -d/)
STAGE?=dev

COMMIT=$(shell git rev-parse --short HEAD)
TAG?=$(shell printf '%s_%s_%08d' ${VERSION} ${COMMIT} ${GITHUB_RUN_NUMBER})

${TAG}:
@echo ${TAG}

IMAGE?=${NAME}/${STAGE}
REPO?=${ECR}/${IMAGE}


all: image

clean:
@echo

image:
@echo Building ${NAME}:${TAG} ...
@docker build --build-arg REGISTRY_VERSION=$(VERSION) \
--tag ${NAME}:${TAG} \
.
@echo Done.

publish: image
@echo Publishing image: ${REPO}:${TAG} ...
@docker tag ${NAME}:${TAG} ${REPO}:${TAG}
@docker push ${REPO}:${TAG} 2>&1
@echo Done.

realclean: clean
@rm -f ${GITHUB_TOKEN} ${BUNDLE_CFG}

tag:
@echo ${TAG}

vars:
@echo "Docker: ${REPO}:${TAG}"
@echo "ACCOUNT = ${ACCOUNT}"
@echo "ECR = ${ECR}"
@echo "NAME = ${NAME}"
@echo "STAGE = ${STAGE}"
@echo "COMMIT = ${COMMIT}"
@echo "TAG = ${TAG}"
@echo "VERSION = ${VERSION}"
9 changes: 9 additions & 0 deletions deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
name: epimorphics/env-registry
deployments:
- branch: "production"
publish: "production"
- branch: "uat"
publish: "uat"
- branch: "master"
publish: "dev"

0 comments on commit 135a567

Please sign in to comment.