Skip to content

Commit

Permalink
Workflow and makefile updates
Browse files Browse the repository at this point in the history
# Subject
Applies a universal github workflow and standard makefile commands to the app.

# Why these changes are being introduced:
This commit is part of a larger refactor of how we handle ECR repositories and generating makefile and github workflows.
The work here will likely be removed when stage and prod are deployed, so this is a temporary change, but serves as a proof of concept/stopgap until stage is ready.
The changes here represent a direct copy/paste from the infrastructure repository.

# How this addresses that need:
Add the dev-build workflow
Update the makefile with our new standard format

# Side effects of this change:
A test of this workflow will happen when I submit the PR for this.

# Relevant ticket(s):
NA
  • Loading branch information
zotoMIT committed Jun 2, 2022
1 parent d5b00c8 commit 5ee7108
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 52 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### This is the Terraform-generated dev-build.yml workflow for the alma-webhook-lambdas-dev app repository ###
name: dev Build and Deploy lambda Container
on:
workflow_dispatch:
pull_request:
branches:
- main
paths-ignore:
- '.github/**'

jobs:
deploy:
name: dev Deploy lambda Container
uses: mitlibraries/.github/.github/workflows/lambda-shared-deploy-dev.yml@container-flows
secrets: inherit
with:
AWS_REGION: "us-east-1"
GHA_ROLE: "alma-webhook-lambdas-gha-dev"
ECR: "alma-webhook-lambdas-dev"
FUNCTION: "alma-webhook-lambdas-dev"
38 changes: 0 additions & 38 deletions .github/workflows/dev_ecr_push.yml

This file was deleted.

32 changes: 18 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
### This is the Terraform-generated header for the timdex-pipeline-lambads Makefile ###
SHELL=/bin/bash
DATETIME:=$(shell date -u +%Y%m%dT%H%M%SZ)
ECR_REGISTRY_DEV=$(shell aws sts get-caller-identity --query Account --output text).dkr.ecr.us-east-1.amazonaws.com
### This is the Terraform-generated header for alma-webhook-lambdas-dev
ECR_NAME_DEV:=alma-webhook-lambdas-dev
ECR_URL_DEV:=222053980223.dkr.ecr.us-east-1.amazonaws.com/alma-webhook-lambdas-dev
FUNCTION_DEV:=alma-webhook-lambdas-dev
### End of Terraform-generated header ###

help: ## Print this message
@awk 'BEGIN { FS = ":.*##"; print "Usage: make <target>\n\nTargets:" } \
Expand Down Expand Up @@ -41,20 +46,19 @@ isort:
mypy:
pipenv run mypy lambdas

### Container commands ###
dist-dev: ## Build docker container
### Developer Deploy Commands ###
dist-dev: ## Build docker container (intended for developer-based manual build)
docker build --platform linux/amd64 \
-t $(ECR_REGISTRY_DEV)/alma-webhook-lambdas-dev:latest \
-t $(ECR_REGISTRY_DEV)/alma-webhook-lambdas-dev:`git describe --always` \
-t alma-webhook-lambdas-dev:latest .
-t $(ECR_URL_DEV):latest \
-t $(ECR_URL_DEV):`git describe --always` \
-t $(ECR_NAME_DEV):latest .

publish-dev: dist-dev ## Build, tag and push
docker login -u AWS -p $$(aws ecr get-login-password --region us-east-1) $(ECR_REGISTRY_DEV)
docker push $(ECR_REGISTRY_DEV)/alma-webhook-lambdas-dev:latest
docker push $(ECR_REGISTRY_DEV)/alma-webhook-lambdas-dev:`git describe --always`
publish-dev: dist-dev ## Build, tag and push (intended for developer-based manual publish)
docker login -u AWS -p $$(aws ecr get-login-password --region us-east-1) $(ECR_URL_DEV)
docker push $(ECR_URL_DEV):latest
docker push $(ECR_URL_DEV):`git describe --always`

update-lambda-dev: ## Updates the lambda with whatever is the most recent image in the ecr
update-lambda-dev: ## Updates the lambda with whatever is the most recent image in the ecr (intended for developer-based manual update)
aws lambda update-function-code \
--function-name alma-webhook-lambdas-dev \
--image-uri $(shell aws sts get-caller-identity --query Account --output text).dkr.ecr.us-east-1.amazonaws.com/alma-webhook-lambdas-dev:latest

--function-name $(FUNCTION_DEV) \
--image-uri $(ECR_URL_DEV):latest

0 comments on commit 5ee7108

Please sign in to comment.