-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
83 lines (77 loc) · 2.86 KB
/
Copy pathaction.yml
File metadata and controls
83 lines (77 loc) · 2.86 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: 'Publish Lambda Layer'
description: 'Publish a Lambda Layer to AWS based on a requirements.txt'
inputs:
aws-access-key-id:
description: 'AWS access key id'
required: true
aws-secret-access-key:
description: 'AWS secret access key'
required: true
aws-default-region:
description: 'AWS default region'
required: false
default: 'us-east-1'
working-directory:
description: 'The relative path of a directory containing the requirements.txt'
required: false
default: './'
layer-name:
description: 'The name of the layer'
required: true
default: ''
python-runtime:
description: 'The compatible python runtime, e.g.: python3.8'
required: false
default: 'python3.8'
additional-python-runtimes:
description: 'A space-delimited list of additional compatible python runtimes, e.g.: python3.7 python3.6'
required: false
default: ''
outputs:
output:
description: 'The output of aws lambda publish-layer-version in compact JSON format (https://docs.aws.amazon.com/cli/latest/reference/lambda/publish-layer-version.html#output)'
value: ${{ steps.publish-layer.outputs.output }}
runs:
using: 'composite'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Python version
id: set-python-version
shell: bash
run: |
python_version=$(echo ${{ inputs.python-runtime }} | sed 's/python//g')
echo "python_version=${python_version}" >> $GITHUB_OUTPUT
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ steps.set-python-version.outputs.python_version }}
- name: Create Layer Bundle
working-directory: ${{ inputs.working-directory }}
env:
PYTHON_VERSION: ${{ steps.set-python-version.outputs.python_version }}
shell: bash
run: |
pip install -r requirements.txt -t python/lib/${PYTHON_VERSION}/site-packages/
zip -r layer.zip python > /dev/null
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ inputs.aws-access-key-id }}
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
aws-region: ${{ inputs.aws-default-region }}
- name: Publish Lambda Layer to AWS
working-directory: ${{ inputs.working-directory }}
id: publish-layer
env:
LAYER_NAME: ${{ inputs.layer-name }}
RUNTIME: ${{ inputs.python-runtime }}
ADDITIONAL_RUNTIMES: ${{ inputs.additional-python-runtimes }}
shell: bash
run: |
aws lambda publish-layer-version \
--layer-name $LAYER_NAME \
--zip-file fileb://layer.zip \
--compatible-runtimes $RUNTIME $ADDITIONAL_RUNTIMES \
| jq --compact-output '.' > publish-layer-output.json
echo "output=$(cat publish-layer-output.json)" >> $GITHUB_OUTPUT