-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (41 loc) · 1.53 KB
/
deploy-lambda-function.yaml
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
name: Deploy to AWS Lambda
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Log in to Amazon ECR
id: login-ecr
uses: jwalton/gh-ecr-login@v1
with:
region: ${{ secrets.AWS_REGION }}
access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Run Tests
id: run-tests
run: |
pip3 install --no-cache-dir -r requirements.txt
pip3 install --no-cache-dir -r requirements-dev.txt
pytest .
- name: Build, tag, and push Docker image
id: build-image
run: |
ECR_REGISTRY=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
ECR_REPOSITORY=${ECR_REGISTRY}/${IMAGE_NAME}
docker build -t ${IMAGE_NAME} .
docker tag ${IMAGE_NAME}:latest ${ECR_REPOSITORY}:latest
docker push ${ECR_REPOSITORY}:latest
env:
IMAGE_NAME: uv-warning-bot-lambda
- name: Update Lambda function
run: |
aws lambda update-function-code --function-name uv-warning-bot-lambda --image-uri ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/uv-warning-bot-lambda:latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}