1- name : Prod-cd-lambda
1+ name : Deploy Lambda Functions - Prod
22
33on :
44 push :
5- branches : [ main ]
6-
7- permissions :
8- contents : read
5+ branches :
6+ - main
7+ paths :
8+ - ' edukit-AI-agent-1/**'
9+ - ' edukit-AI-agent-2/**'
910
1011jobs :
11- deploy-agent1 :
12- name : Deploy AI Agent 1
12+ detect-changes :
1313 runs-on : ubuntu-latest
14+ outputs :
15+ agent1-changed : ${{ steps.changes.outputs.agent1 }}
16+ agent2-changed : ${{ steps.changes.outputs.agent2 }}
1417 steps :
15- - name : Checkout
16- uses : actions/checkout@v4
17-
18- - name : Setup Python
19- uses : actions/setup-python@v5
18+ - uses : actions/checkout@v4
2019 with :
21- python-version : ' 3.11'
22-
23- - name : Install tooling
24- run : |
25- sudo apt-get update
26- sudo apt-get install -y zip
27- pip install --upgrade pip
28- pip install awscli
29-
30- - name : Configure AWS Credentials
31- uses : aws-actions/configure-aws-credentials@v4
20+ fetch-depth : 2
21+
22+ - uses : dorny/paths-filter@v2
23+ id : changes
3224 with :
33- aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
34- aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
35- aws-region : ${{ secrets.AWS_REGION }}
25+ filters : |
26+ agent1:
27+ - 'edukit-AI-agent-1/**'
28+ agent2:
29+ - 'edukit-AI-agent-2/**'
3630
37- - name : Package Lambda (agent1)
31+ deploy-agent-1 :
32+ needs : detect-changes
33+ if : needs.detect-changes.outputs.agent1-changed == 'true'
34+ runs-on : ubuntu-latest
35+ environment : prod
36+ steps :
37+ - uses : actions/checkout@v4
38+
39+ - name : Set up Python
40+ uses : actions/setup-python@v4
41+ with :
42+ python-version : ' 3.13'
43+
44+ - name : Install dependencies
45+ working-directory : ./edukit-AI-agent-1
3846 run : |
39- cd edukit-AI-agent-1
40- zip -r9 ../agent1.zip lambda_function.py
41- cd package
42- zip -r9 ../../agent1.zip .
43-
44- - name : Deploy Lambda (agent1)
47+ pip install \
48+ --platform manylinux2014_x86_64 \
49+ --target=./package \
50+ --implementation cp \
51+ --python-version 3.13 \
52+ --only-binary=:all: \
53+ --upgrade \
54+ -r requirements.txt
55+
56+ - name : Create deployment package
57+ working-directory : ./edukit-AI-agent-1
4558 run : |
46- aws lambda update-function-code \
47- --function-name ${{ secrets.LAMBDA_FUNCTION_NAME_AGENT_1 }} \
48- --zip-file fileb://agent1.zip
59+ cd package
60+ zip -r ../deployment-package.zip .
61+ cd ..
62+ zip -g deployment-package.zip lambda_function.py
63+
64+ - name : Deploy to AWS Lambda
65+ uses : appleboy/lambda-action@v0.1.9
66+ with :
67+ aws_access_key_id : ${{ secrets.AWS_ACCESS_KEY_ID }}
68+ aws_secret_access_key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
69+ aws_region : ${{ secrets.AWS_REGION }}
70+ function_name : ${{ secrets.LAMBDA_FUNCTION_NAME_AGENT_1 }}
71+ zip_file : ./edukit-AI-agent-1/deployment-package.zip
4972
50- deploy-agent2 :
51- name : Deploy AI Agent 2
73+ deploy-agent-2 :
74+ needs : detect-changes
75+ if : needs.detect-changes.outputs.agent2-changed == 'true'
5276 runs-on : ubuntu-latest
53- needs : deploy-agent1
77+ environment : prod
5478 steps :
55- - name : Checkout
56- uses : actions/checkout@v4
57-
58- - name : Setup Python
59- uses : actions/setup-python@v5
79+ - uses : actions/checkout@v4
80+
81+ - name : Set up Python
82+ uses : actions/setup-python@v4
6083 with :
61- python-version : ' 3.11'
62-
63- - name : Install tooling
84+ python-version : ' 3.13'
85+
86+ - name : Install dependencies
87+ working-directory : ./edukit-AI-agent-2
6488 run : |
65- sudo apt-get update
66- sudo apt-get install -y zip
67- pip install --upgrade pip
68- pip install awscli
69-
70- - name : Configure AWS Credentials
71- uses : aws-actions/configure-aws-credentials@v4
72- with :
73- aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
74- aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
75- aws-region : ${{ secrets.AWS_REGION }}
76-
77- - name : Package Lambda (agent2)
89+ pip install \
90+ --platform manylinux2014_x86_64 \
91+ --target=./package \
92+ --implementation cp \
93+ --python-version 3.13 \
94+ --only-binary=:all: \
95+ --upgrade \
96+ -r requirements.txt
97+
98+ - name : Create deployment package
99+ working-directory : ./edukit-AI-agent-2
78100 run : |
79- cd edukit-AI-agent-2
80- zip -r9 ../agent2.zip lambda_function.py
81101 cd package
82- zip -r9 ../../agent2.zip .
83-
84- - name : Deploy Lambda (agent2)
85- run : |
86- aws lambda update-function-code \
87- --function-name ${{ secrets.LAMBDA_FUNCTION_NAME_AGENT_2 }} \
88- --zip-file fileb://agent2.zip
102+ zip -r ../deployment-package.zip .
103+ cd ..
104+ zip -g deployment-package.zip lambda_function.py
105+
106+ - name : Deploy to AWS Lambda
107+ uses : appleboy/lambda-action@v0.1.9
108+ with :
109+ aws_access_key_id : ${{ secrets.AWS_ACCESS_KEY_ID }}
110+ aws_secret_access_key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
111+ aws_region : ${{ secrets.AWS_REGION }}
112+ function_name : ${{ secrets.LAMBDA_FUNCTION_NAME_AGENT_2 }}
113+ zip_file : ./edukit-AI-agent-2/deployment-package.zip
0 commit comments