-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (113 loc) · 6.98 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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