Merge pull request #46 from l3fdb33f/Mul3_add #73
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |