Skip to content
This repository was archived by the owner on Jul 20, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ Storing credentials as a Github secret is strongly recommended.
Same as above if you need more layers.
- `custom_layer_4_arn`
Same as above if you need more layers.
- `public_layer_1_arn`
The ARN of an external public Lambda layer in case you need one (e.g. https://github.com/keithrozario/Klayers).
- `public_layer_2_arn`
Same as above if you need more layers.
- `public_layer_3_arn`
Same as above if you need more layers.
- `public_layer_4_arn`
Same as above if you need more layers.
- `lambda_function_names`
The Lambda function names comma separated.
- `aws_region`
Expand Down
12 changes: 12 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ inputs:
description: the path to the code for custom layer 4
custom_layer_4_arn:
description: the ARN for custom layer 4
public_layer_1_arn:
description: the ARN for public layer 1
public_layer_2_arn:
description: the ARN for public layer 2
public_layer_3_arn:
description: the ARN for public layer 3
public_layer_4_arn:
description: the ARN for public layer 4
lambda_function_names:
description: The Lambda function names (comma-separated if you have multiple). Check the AWS docs/readme for examples.
required: true
Expand All @@ -47,6 +55,10 @@ runs:
- ${{ inputs.custom_layer_3_arn }}
- ${{ inputs.custom_layer_4_path }}
- ${{ inputs.custom_layer_4_arn }}
- ${{ inputs.public_layer_1_arn }}
- ${{ inputs.public_layer_2_arn }}
- ${{ inputs.public_layer_3_arn }}
- ${{ inputs.public_layer_4_arn }}
branding:
icon: 'cloud-lightning'
color: 'white'
55 changes: 47 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ publish_custom_layers(){
ALL_LAYERS_ARN_VERSION+=" ${INPUT_CUSTOM_LAYER_1_ARN}:${CUSTOM_LAYER_1_VERSION}"
rm -rf python
rm custom_layer_1.zip
rm -rf ${INPUT_CUSTOM_LAYER_1_PATH}
fi

if [ -z ${INPUT_CUSTOM_LAYER_2_PATH} ]; then
Expand All @@ -62,6 +63,7 @@ publish_custom_layers(){
ALL_LAYERS_ARN_VERSION+=" ${INPUT_CUSTOM_LAYER_2_ARN}:${CUSTOM_LAYER_2_VERSION}"
rm -rf python
rm custom_layer_2.zip
rm -rf ${INPUT_CUSTOM_LAYER_2_PATH}
fi

if [ -z ${INPUT_CUSTOM_LAYER_3_PATH} ]; then
Expand All @@ -83,6 +85,7 @@ publish_custom_layers(){
ALL_LAYERS_ARN_VERSION+=" ${INPUT_CUSTOM_LAYER_3_ARN}:${CUSTOM_LAYER_3_VERSION}"
rm -rf python
rm custom_layer_3.zip
rm -rf ${INPUT_CUSTOM_LAYER_3_PATH}
fi

if [ -z ${INPUT_CUSTOM_LAYER_4_PATH} ]; then
Expand All @@ -104,18 +107,49 @@ publish_custom_layers(){
ALL_LAYERS_ARN_VERSION+=" ${INPUT_CUSTOM_LAYER_4_ARN}:${CUSTOM_LAYER_4_VERSION}"
rm -rf python
rm custom_layer_4.zip
rm -rf ${INPUT_CUSTOM_LAYER_4_PATH}
fi
}

publish_function(){
echo "Deploying the code for ${1}"
cd "${1}"
zip -r code.zip .
aws lambda update-function-code --function-name "${1}" --zip-file fileb://code.zip
rm code.zip
cd ..
publish_public_layers(){
if [ -z ${INPUT_PUBLIC_LAYER_1_ARN} ]; then
echo "public_layer_1_arn is not set"
else
echo "Publishing public layer 1"
ALL_LAYERS_ARN_VERSION+=" ${INPUT_PUBLIC_LAYER_1_ARN}"
fi

if [ -z ${INPUT_PUBLIC_LAYER_2_ARN} ]; then
echo "public_layer_1_arn is not set"
else
echo "Publishing public layer 1"
ALL_LAYERS_ARN_VERSION+=" ${INPUT_PUBLIC_LAYER_2_ARN}"
fi

if [ -z ${INPUT_PUBLIC_LAYER_3_ARN} ]; then
echo "public_layer_1_arn is not set"
else
echo "Publishing public layer 1"
ALL_LAYERS_ARN_VERSION+=" ${INPUT_PUBLIC_LAYER_3_ARN}"
fi

if [ -z ${INPUT_PUBLIC_LAYER_4_ARN} ]; then
echo "public_layer_1_arn is not set"
else
echo "Publishing public layer 1"
ALL_LAYERS_ARN_VERSION+=" ${INPUT_PUBLIC_LAYER_4_ARN}"
fi
}

# publish_function(){
# echo "Deploying the code for ${1}"
# # cd "${1}"
# zip -r code.zip .
# aws lambda update-function-code --function-name "${1}" --zip-file fileb://code.zip
# rm code.zip
# # cd ..
# }

update_function_layers(){
echo "Adding pip layer and custom layers to ${1}"
echo ${ALL_LAYERS_ARN_VERSION[@]}
Expand All @@ -126,12 +160,17 @@ deploy_lambda_function(){
configure_aws_credentials
publish_pip_layer
publish_custom_layers
publish_public_layers

functionNames=(${INPUT_LAMBDA_FUNCTION_NAMES//,/ })
zip -r code.zip .
for name in ${functionNames[@]}; do
publish_function $name
echo "Deploying the code for ${1}"
aws lambda update-function-code --function-name "${1}" --zip-file fileb://code.zip
# publish_function $name
update_function_layers $name
done
rm code.zip
}

deploy_lambda_function
Expand Down