-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (60 loc) · 2.1 KB
/
ci.yml
File metadata and controls
72 lines (60 loc) · 2.1 KB
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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: docker_image/requirements.txt
- name: Install dependencies
run: |
pip install -r docker_image/requirements.txt
pip install pytest httpx
- name: Run tests
run: PYTHONPATH=docker_image/src pytest tests/ -v
docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Docker image
run: docker build -t rag-app docker_image/
deploy:
needs: [test, docker-build]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
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: Build and push Docker image
run: |
docker build \
--build-arg AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
--build-arg AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
-t rag-app docker_image/
docker tag rag-app:latest ${{ secrets.ECR_REPOSITORY_URI }}:latest
docker push ${{ secrets.ECR_REPOSITORY_URI }}:latest
- name: Update Lambda function
run: |
aws lambda update-function-code \
--function-name ${{ secrets.LAMBDA_FUNCTION_NAME }} \
--image-uri ${{ secrets.ECR_REPOSITORY_URI }}:latest
aws lambda wait function-updated-v2 \
--function-name ${{ secrets.LAMBDA_FUNCTION_NAME }}
echo "Lambda function updated successfully."