diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml new file mode 100644 index 0000000..09e11c1 --- /dev/null +++ b/.github/workflows/dev-build.yml @@ -0,0 +1,20 @@ +### This is the Terraform-generated dev-build.yml workflow for the ppod-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: "ppod-gha-dev" + ECR: "ppod-dev" + FUNCTION: "ppod-dev" diff --git a/.github/workflows/dev_ecr_push.yml b/.github/workflows/dev_ecr_push.yml deleted file mode 100644 index 4a1c5e4..0000000 --- a/.github/workflows/dev_ecr_push.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: dev ECR push -on: - push: - branches: - - main -# Set defaults -defaults: - run: - shell: bash - -env: - AWS_REGION: "us-east-1" - AWS_ACCOUNT_ID: "222053980223" - IAM_ROLE: "ppod-gha-dev" - -jobs: - deploy: - name: Deploy dev build - runs-on: ubuntu-latest - # These permissions are needed to interact with GitHub's OIDC Token endpoint. - permissions: - id-token: write - contents: read - - steps: - - uses: actions/checkout@v2 - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/${{ env.IAM_ROLE }} - aws-region: ${{ env.AWS_REGION }} - - - name: Build image - run: make dist-dev - - name: Push image - run: make publish-dev - - name: Update lambda function - run: make update-lambda-dev \ No newline at end of file diff --git a/Makefile b/Makefile index f9058ee..5fcd37d 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,10 @@ 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 ppod-dev +ECR_NAME_DEV:=ppod-dev +ECR_URL_DEV:=222053980223.dkr.ecr.us-east-1.amazonaws.com/ppod-dev +FUNCTION_DEV:=ppod-dev +### End of Terraform-generated header ### help: ## Print this message @awk 'BEGIN { FS = ":.*##"; print "Usage: make \n\nTargets:" } \ @@ -41,19 +45,19 @@ isort: mypy: pipenv run mypy . -### 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)/ppod-dev:latest \ - -t $(ECR_REGISTRY_DEV)/ppod-dev:`git describe --always` \ - -t ppod-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)/ppod-dev:latest - docker push $(ECR_REGISTRY_DEV)/ppod-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 ppod-dev \ - --image-uri $(shell aws sts get-caller-identity --query Account --output text).dkr.ecr.us-east-1.amazonaws.com/ppod-dev:latest + --function-name $(FUNCTION_DEV) \ + --image-uri $(ECR_URL_DEV):latest