Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add string of files to exclude as optional input parameter. #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -29,7 +29,8 @@ Stored as secrets or env vars, doesn't matter. But also please don't put your AW
- Partial ARN - `123456789012:function:my-function`
- `requirements_txt`
The name/path for the `requirements.txt` file. Defaults to `requirements.txt`.

- `exclude_files`
(Optional) A string of files or folders to exclude, delimited by whitespace.

### Example workflow
```yaml
@@ -49,9 +50,10 @@ jobs:
with:
lambda_layer_arn: 'arn:aws:lambda:us-east-2:123456789012:layer:my-layer'
lambda_function_name: 'my-function'
exclude_files: 'tests my-other-file.txt'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'us-east-2'

```
```
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -12,13 +12,18 @@ inputs:
lambda_function_name:
description: The Lambda function name. Check the AWS docs/readme for examples.
required: true
exclude_files:
description: A string of files or folders to exclude, delimited by whitespace.
required: false
default: ''
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.requirements_txt }}
- ${{ inputs.lambda_layer_arn }}
- ${{ inputs.lambda_function_name }}
- ${{ inputs.exclude_files }}
branding:
icon: 'layers'
color: 'yellow'
15 changes: 13 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -e
set -euo pipefail

install_zip_dependencies(){
echo "Installing and zipping dependencies..."
@@ -16,10 +16,21 @@ publish_dependencies_as_layer(){
rm dependencies.zip
}

files_to_exclude() {
echo "exclude.lst" > exclude.lst
echo ".git/*" >> exclude.lst
read -ra ADDR <<< "$INPUT_EXCLUDE_FILES"
for i in "${ADDR[@]}"; do
echo "$i*" >> exclude.lst
done
}

publish_function_code(){
echo "Deploying the code itself..."
zip -r code.zip . -x \*.git\*
files_to_exclude
zip -r code.zip . [email protected]
aws lambda update-function-code --function-name "${INPUT_LAMBDA_FUNCTION_NAME}" --zip-file fileb://code.zip
rm exclude.lst
}

update_function_layers(){