commit lambda #268
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Lambdas & Terraform Plan on PR | |
env: | |
RICH_PDF_INGESTION_ECR_NAME: rich_pdf_ingestion | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy_lambda: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Create ECR repository if it doesn't exist | |
run: | | |
aws ecr describe-repositories --repository-names ${{ vars.INFERENCE_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.INFERENCE_ECR_NAME }} | |
aws ecr describe-repositories --repository-names ${{ vars.INGESTION_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.INGESTION_ECR_NAME }} | |
aws ecr describe-repositories --repository-names ${{ vars.LEX_ROUTER_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.LEX_ROUTER_ECR_NAME }} | |
aws ecr describe-repositories --repository-names ${{ vars.LIST_COLLECTIONS_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.LIST_COLLECTIONS_ECR_NAME }} | |
aws ecr describe-repositories --repository-names ${{ vars.MEMORY_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.MEMORY_ECR_NAME }} | |
aws ecr describe-repositories --repository-names ${{ vars.RESUME_REQUEST_PROCESSOR_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.RESUME_REQUEST_PROCESSOR_ECR_NAME }} | |
aws ecr describe-repositories --repository-names ${{ vars.RESUME_REQUEST_PREPROCESSOR_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.RESUME_REQUEST_PREPROCESSOR_ECR_NAME }} | |
aws ecr describe-repositories --repository-names ${{ vars.RESUME_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.RESUME_ECR_NAME }} | |
aws ecr describe-repositories --repository-names ${{ env.RICH_PDF_INGESTION_ECR_NAME }} || aws ecr create-repository --repository-name ${{ env.RICH_PDF_INGESTION_ECR_NAME }} | |
- name: Generate timestamp | |
id: timestamp | |
run: echo "::set-output name=timestamp::$(date +%s)" | |
- name: Build, tag, and push image to Amazon ECR | |
id: build-image | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
IMAGE_TAG: ${{ steps.timestamp.outputs.timestamp }} | |
run: | | |
docker build -t $ECR_REGISTRY/${{ vars.INFERENCE_ECR_NAME }}:$IMAGE_TAG ./lambdas/${{ vars.INFERENCE_ECR_NAME }}/src | |
docker push $ECR_REGISTRY/${{ vars.INFERENCE_ECR_NAME }}:$IMAGE_TAG | |
docker build -t $ECR_REGISTRY/${{ vars.INGESTION_ECR_NAME }}:$IMAGE_TAG ./lambdas/${{ vars.INGESTION_ECR_NAME }}/src | |
docker push $ECR_REGISTRY/${{ vars.INGESTION_ECR_NAME }}:$IMAGE_TAG | |
docker build -t $ECR_REGISTRY/${{ vars.LEX_ROUTER_ECR_NAME }}:$IMAGE_TAG ./lambdas/${{ vars.LEX_ROUTER_ECR_NAME }}/src | |
docker push $ECR_REGISTRY/${{ vars.LEX_ROUTER_ECR_NAME }}:$IMAGE_TAG | |
docker build -t $ECR_REGISTRY/${{ vars.LIST_COLLECTIONS_ECR_NAME }}:$IMAGE_TAG ./lambdas/${{ vars.LIST_COLLECTIONS_ECR_NAME }}/src | |
docker push $ECR_REGISTRY/${{ vars.LIST_COLLECTIONS_ECR_NAME }}:$IMAGE_TAG | |
docker build -t $ECR_REGISTRY/${{ vars.MEMORY_ECR_NAME }}:$IMAGE_TAG ./lambdas/${{ vars.MEMORY_ECR_NAME }}/src | |
docker push $ECR_REGISTRY/${{ vars.MEMORY_ECR_NAME }}:$IMAGE_TAG | |
docker build -t $ECR_REGISTRY/${{ vars.RESUME_REQUEST_PROCESSOR_ECR_NAME }}:$IMAGE_TAG ./lambdas/ResumeProcessor/ResumeRequestProcessorFunction | |
docker push $ECR_REGISTRY/${{ vars.RESUME_REQUEST_PROCESSOR_ECR_NAME }}:$IMAGE_TAG | |
docker build -t $ECR_REGISTRY/${{ vars.RESUME_REQUEST_PREPROCESSOR_ECR_NAME }}:$IMAGE_TAG ./lambdas/ResumeProcessor/ResumeRequestPreProcessorFunction | |
docker push $ECR_REGISTRY/${{ vars.RESUME_REQUEST_PREPROCESSOR_ECR_NAME }}:$IMAGE_TAG | |
docker build -t $ECR_REGISTRY/${{ vars.RESUME_ECR_NAME }}:$IMAGE_TAG ./lambdas/ResumeProcessor/ResumeFunction | |
docker push $ECR_REGISTRY/${{ vars.RESUME_ECR_NAME }}:$IMAGE_TAG | |
docker build -t $ECR_REGISTRY/${{ env.RICH_PDF_INGESTION_ECR_NAME }}:$IMAGE_TAG ./lambdas/${{ env.RICH_PDF_INGESTION_ECR_NAME }}/src | |
docker push $ECR_REGISTRY/${{ env.RICH_PDF_INGESTION_ECR_NAME }}:$IMAGE_TAG | |
deploy-infra: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
needs: [deploy_lambda] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Set up Java 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'corretto' | |
java-version: '17' | |
cache: maven | |
- name: Package Java lambdas | |
run: | | |
mvn -f ./lambdas/EmailProcessor/EmailRequestPreProcessorFunction package | |
mvn -f ./lambdas/EmailProcessor/EmailResponseProcessorFunction package | |
mvn -f ./lambdas/EmailProcessor/EmailRequestProcessorFunction package | |
mvn -f ./lambdas/AttachmentSaver/AttachmentSaverFunction package | |
mvn -f ./lambdas/FormProcessor/FormRequestPreProcessorFunction package | |
mvn -f ./lambdas/FormProcessor/FormRequestProcessorFunction package | |
mvn -f ./lambdas/TranscriptionProcessor/TranscriptionFunction package | |
mvn -f ./lambdas/TranscriptionProcessor/TranscriptionFormatterFunction package | |
- name: Terraform Init | |
id: init | |
working-directory: ${{ vars.TF_ACTIONS_WORKING_DIR }} | |
run: terraform init -no-color -upgrade | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v3 | |
- name: Terraform Apply | |
working-directory: ${{ vars.TF_ACTIONS_WORKING_DIR }} | |
run: | | |
terraform apply \ | |
-var="ingestion_repository_name=${{ vars.INGESTION_ECR_NAME }}" \ | |
-var="inference_repository_name=${{ vars.INFERENCE_ECR_NAME }}" \ | |
-var="memory_repository_name=${{ vars.MEMORY_ECR_NAME }}" \ | |
-var="list_collections_repository_name=${{ vars.LIST_COLLECTIONS_ECR_NAME }}" \ | |
-var="lex_router_repository_name=${{ vars.LEX_ROUTER_ECR_NAME }}" \ | |
-var="sender_email=${{ vars.SENDER_EMAIL }}" \ | |
-var="resume_request_processor_lambda_repository_name=${{ vars.RESUME_REQUEST_PROCESSOR_ECR_NAME }}" \ | |
-var="resume_request_preprocessor_lambda_repository_name=${{ vars.RESUME_REQUEST_PREPROCESSOR_ECR_NAME }}" \ | |
-var="resume_lambda_repository_name=${{ vars.RESUME_ECR_NAME }}" \ | |
-var="rich_pdf_ingestion_repository_name=${{ env.RICH_PDF_INGESTION_ECR_NAME }}" \ | |
-auto-approve -no-color -input=false |