-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (126 loc) · 9.64 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Deploy Lambdas & Terraform Plan on PR
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.EMAIL_REQUEST_PROCESSOR_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.EMAIL_REQUEST_PROCESSOR_ECR_NAME }}
aws ecr describe-repositories --repository-names ${{ vars.EMAIL_RESPONSE_PROCESSOR_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.EMAIL_RESPONSE_PROCESSOR_ECR_NAME }}
aws ecr describe-repositories --repository-names ${{ vars.ATTACHMENT_SAVER_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.ATTACHMENT_SAVER_ECR_NAME }}
aws ecr describe-repositories --repository-names ${{ vars.TRANSCRIPTION_PROCESSOR_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.TRANSCRIPTION_PROCESSOR_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 ${{ vars.TRANSCRIPTION_FORMATTER_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.TRANSCRIPTION_FORMATTER_ECR_NAME }}
aws ecr describe-repositories --repository-names ${{ vars.FORM_REQUEST_PROCESSOR_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.FORM_REQUEST_PROCESSOR_ECR_NAME }}
aws ecr describe-repositories --repository-names ${{ vars.FORM_REQUEST_PREPROCESSOR_ECR_NAME }} || aws ecr create-repository --repository-name ${{ vars.FORM_REQUEST_PREPROCESSOR_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.EMAIL_REQUEST_PROCESSOR_ECR_NAME }}:$IMAGE_TAG ./lambdas/EmailProcessor/EmailRequestProcessorFunction
docker push $ECR_REGISTRY/${{ vars.EMAIL_REQUEST_PROCESSOR_ECR_NAME }}:$IMAGE_TAG
docker build -t $ECR_REGISTRY/${{ vars.EMAIL_RESPONSE_PROCESSOR_ECR_NAME }}:$IMAGE_TAG ./lambdas/EmailProcessor/EmailResponseProcessorFunction
docker push $ECR_REGISTRY/${{ vars.EMAIL_RESPONSE_PROCESSOR_ECR_NAME }}:$IMAGE_TAG
docker build -t $ECR_REGISTRY/${{ vars.ATTACHMENT_SAVER_ECR_NAME }}:$IMAGE_TAG ./lambdas/AttachmentSaver/AttachmentSaverFunction
docker push $ECR_REGISTRY/${{ vars.ATTACHMENT_SAVER_ECR_NAME }}:$IMAGE_TAG
docker build -t $ECR_REGISTRY/${{ vars.TRANSCRIPTION_PROCESSOR_ECR_NAME }}:$IMAGE_TAG ./lambdas/TranscriptionProcessor/TranscriptionFunction
docker push $ECR_REGISTRY/${{ vars.TRANSCRIPTION_PROCESSOR_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/${{ vars.TRANSCRIPTION_FORMATTER_ECR_NAME }}:$IMAGE_TAG ./lambdas/TranscriptionProcessor/TranscriptionFormatterFunction
docker push $ECR_REGISTRY/${{ vars.TRANSCRIPTION_FORMATTER_ECR_NAME }}:$IMAGE_TAG
docker build -t $ECR_REGISTRY/${{ vars.FORM_REQUEST_PROCESSOR_ECR_NAME }}:$IMAGE_TAG ./lambdas/FormProcessor/FormRequestProcessorFunction
docker push $ECR_REGISTRY/${{ vars.FORM_REQUEST_PROCESSOR_ECR_NAME }}:$IMAGE_TAG
docker build -t $ECR_REGISTRY/${{ vars.FORM_REQUEST_PREPROCESSOR_ECR_NAME }}:$IMAGE_TAG ./lambdas/FormProcessor/FormRequestPreProcessorFunction
docker push $ECR_REGISTRY/${{ vars.FORM_REQUEST_PREPROCESSOR_ECR_NAME }}:$IMAGE_TAG
deploy-infra:
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'
- name: Package Java lambdas
run: |
mvn -f ./lambdas/EmailProcessor/EmailRequestPreProcessorFunction package
zip -r ./lambdas/EmailProcessor/EmailRequestPreProcessorFunction/iac/lambda.zip ./lambdas/EmailProcessor/EmailRequestPreProcessorFunction/target/email-request-preprocessor-1.0.jar
- 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="email_request_processor_lambda_repository_name=${{ vars.EMAIL_REQUEST_PROCESSOR_ECR_NAME }}" \
-var="email_response_processor_lambda_repository_name=${{ vars.EMAIL_RESPONSE_PROCESSOR_ECR_NAME }}" \
-var="sender_email=${{ vars.SENDER_EMAIL }}" \
-var="attachment_saver_lambda_repository_name=${{ vars.ATTACHMENT_SAVER_ECR_NAME }}" \
-var="transcription_processor_lambda_repository_name=${{ vars.TRANSCRIPTION_PROCESSOR_ECR_NAME }}" \
-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="transcription_formatter_lambda_repository_name=${{ vars.TRANSCRIPTION_FORMATTER_ECR_NAME }}" \
-var="form_request_processor_lambda_repository_name=${{ vars.FORM_REQUEST_PROCESSOR_ECR_NAME }}" \
-var="form_request_preprocessor_lambda_repository_name=${{ vars.FORM_REQUEST_PREPROCESSOR_ECR_NAME }}" \
-auto-approve -no-color -input=false