Skip to content

Commit

Permalink
Merge pull request #8 from MITLibraries/automation-update
Browse files Browse the repository at this point in the history
Configure Automated Deploys
  • Loading branch information
cabutlermit committed Jun 14, 2022
2 parents 327f83d + 0d9441d commit e0f3bab
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### This is the Terraform-generated dev-build.yml workflow for the alma-webhook-lambdas-dev app repository ###
name: dev Build and Deploy lambda Container
name: Dev Build and Deploy lambda Container
on:
workflow_dispatch:
pull_request:
Expand All @@ -10,8 +10,8 @@ on:

jobs:
deploy:
name: dev Deploy lambda Container
uses: mitlibraries/.github/.github/workflows/lambda-shared-deploy-dev.yml@container-flows
name: Dev Deploy lambda Container
uses: mitlibraries/.github/.github/workflows/lambda-shared-deploy-dev.yml@main
secrets: inherit
with:
AWS_REGION: "us-east-1"
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/prod-promote.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### This is the Terraform-generated prod-promote.yml workflow for the alma-webhook-lambdas-prod app repository ###
name: Prod Promote Lambda Container
on:
workflow_dispatch:
release:
types: [published]

jobs:
deploy:
name: Prod Promote Lambda Container
uses: mitlibraries/.github/.github/workflows/lambda-shared-promote-prod.yml@main
secrets: inherit
with:
AWS_REGION: "us-east-1"
GHA_ROLE_STAGE: alma-webhook-lambdas-gha-stage
GHA_ROLE_PROD: alma-webhook-lambdas-gha-prod
ECR: "alma-webhook-lambdas-prod"
FUNCTION: "alma-webhook-lambdas-prod"

2 changes: 1 addition & 1 deletion .github/workflows/stage-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
deploy:
name: Stage Deploy Lambda Container
uses: mitlibraries/.github/.github/workflows/lambda-shared-deploy-stage.yml@container-flows
uses: mitlibraries/.github/.github/workflows/lambda-shared-deploy-stage.yml@main
secrets: inherit
with:
AWS_REGION: "us-east-1"
Expand Down
29 changes: 12 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
### 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)
### This is the Terraform-generated header for alma-webhook-lambdas-dev

### 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 ###
### This is the Terraform-generated Makefile header for alma-webhook-lambdas-stage
ECR_NAME_STAGE:=alma-webhook-lambdas-stage
ECR_URL_STAGE:=840055183494.dkr.ecr.us-east-1.amazonaws.com/alma-webhook-lambdas-stage
FUNCTION_STAGE:=alma-webhook-lambdas-stage
### End of Terraform-generated header ###

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

### Developer Deploy Commands ###
### Terraform-generated Developer Deploy Commands for Dev environment ###
dist-dev: ## Build docker container (intended for developer-based manual build)
docker build --platform linux/amd64 \
-t $(ECR_URL_DEV):latest \
Expand All @@ -64,23 +60,22 @@ publish-dev: dist-dev ## Build, tag and push (intended for developer-based manua
docker push $(ECR_URL_DEV):`git describe --always`

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 $(FUNCTION_DEV) \
--image-uri $(ECR_URL_DEV):latest

## Terraform-generated Makefile developer Deploy Commands ###
dist-stage: ## Build docker container (intended for developer-based manual build)
aws lambda update-function-code --function-name $(FUNCTION_DEV) --image-uri $(ECR_URL_DEV):latest

### Terraform-generated manual shortcuts for deploying to Stage ###
### This requires that ECR_NAME_STAGE, ECR_URL_STAGE, and FUNCTION_STAGE environment variables are
### set locally by the developer and that the developer has authenticated to the correct AWS Account.
### The values for the environment variables can be found in the stage_build.yml caller workflow.
dist-stage: ## Only use in an emergency
docker build --platform linux/amd64 \
-t $(ECR_URL_STAGE):latest \
-t $(ECR_URL_STAGE):`git describe --always` \
-t $(ECR_NAME_STAGE):latest .

publish-stage: dist-stage ## Build, tag and push (intended for developer-based manual publish)
publish-stage: ## Only use in an emergency
docker login -u AWS -p $$(aws ecr get-login-password --region us-east-1) $(ECR_URL_STAGE)
docker push $(ECR_URL_STAGE):latest
docker push $(ECR_URL_STAGE):`git describe --always`

update-lambda-stage: ## 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 $(FUNCTION_STAGE) \
--image-uri $(ECR_URL_STAGE):latest
aws lambda update-function-code --function-name $(FUNCTION_STAGE) --image-uri $(ECR_URL_STAGE):latest

0 comments on commit e0f3bab

Please sign in to comment.