-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (56 loc) · 1.79 KB
/
deploy-to-lambda.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
name: Deploy to AWS Lambda
on:
push:
branches:
- deploy
permissions:
contents: write
packages: write
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12.1"
- name: Install dependencies
run: |
python -m pip install --user pipx
python -m pipx ensurepath
pipx install hatch
- name: Create .env file
run: |
echo "${{ secrets.SOLESEARCH_ENV_FILE }}" > .env
shell: bash
- name: Build zip
run: |
hatch build -t zipped-directory
dist_dir="dist/"
zip_file=$(find "$dist_dir" -type f -name "*.zip" -print -quit)
build_file=$(realpath "$zip_file")
echo "Zip file found: $build_file"
hatch env create
HATCH_SITE_PACKAGES_DIR=$(hatch env find)/lib/python3.12/site-packages
cd $HATCH_SITE_PACKAGES_DIR
zip -r $build_file *
cd ${{ github.workspace }}
cp $build_file ${{ github.workspace }}/deploy.zip
shell: bash
- name: Deploy to Lambda
uses: appleboy/[email protected]
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: us-east-1
function_name: solesearch-api
zip_file: deploy.zip
timeout: 10
handler: api.main.handler
runtime: python3.12
role: arn:aws:iam::930702711470:role/service-role/solesearch-api-role-qr34kqa5