-
-
Notifications
You must be signed in to change notification settings - Fork 47
57 lines (47 loc) · 1.98 KB
/
deploy.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
name: AWS Lambda Deploy
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup distribution package
run: |
echo "Building distribution package"
mkdir ./dist
mkdir ./dist/python
mkdir ./dist/python/algorithms
cp *.py ./dist/python
cp -r ./algorithms/* ./dist/python/algorithms/
cd ./dist
zip -r hashdb.zip ./python
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install AWS CLI and tools
run: |
python -m pip install --upgrade pip
pip install awscli
sudo apt-get update
sudo apt-get install -y jq
- name: Publish to AWS Lambda Layer
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
LAMBDA_LAYER_ARN: ${{ secrets.LAMBDA_LAYER_ARN }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
HASHDB_WORKER_LAMBDA_ARN: ${{ secrets.HASHDB_WORKER_LAMBDA_ARN }}
HASHDB_API_LAMBDA_ARN: ${{ secrets.HASHDB_API_LAMBDA_ARN }}
run: |
echo "Publishing as a layer..."
RESULT_DATA=$(aws lambda publish-layer-version --layer-name "$LAMBDA_LAYER_ARN" --zip-file fileb://dist/hashdb.zip)
LAYER_VERSION=$(jq '.Version' <<< "$RESULT_DATA")
echo "Updating hashdb worker to use layer version $LAYER_VERSION..."
UPDATE_RESULT_DATA1=$(aws lambda update-function-configuration --function-name "$HASHDB_WORKER_LAMBDA_ARN" --layers "$LAMBDA_LAYER_ARN:$LAYER_VERSION")
UPDATE_RESULT_DATA2=$(aws lambda update-function-configuration --function-name "$HASHDB_API_LAMBDA_ARN" --layers "$LAMBDA_LAYER_ARN:$LAYER_VERSION")
echo '::set-output name=SELECTED_COLOR::green'
echo "Done"