-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (62 loc) · 2.19 KB
/
layerpipeline.yaml
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
name: Layer Deployment pipeline
permissions:
id-token: write
contents: read
actions: read
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
branches:
- main
paths:
- 'pyproject.toml'
- 'poetry.lock'
- '.github/workflows/**'
jobs:
layer:
name: Dependencies Publish to lambda layer
runs-on: ubuntu-latest
concurrency:
group: lambda-update
cancel-in-progress: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: AWS login
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: gha-lambda-layer-${{ github.event.repository.name }}
aws-region: ${{ vars.AWS_REGION }}
- name: Download & zip dependencies
run: |
pip install -t python .
zip -r layer.zip python
- name: Upload zip to S3
run: aws s3 cp
layer.zip
s3://${{ secrets.AWS_BUCKET }}/${{ github.event.repository.name }}-layer-${{ github.sha }}.zip
--no-progress
- name: Deploy layer for AWS Lambda
run: aws lambda publish-layer-version
--layer-name "${{ github.event.repository.name }}-layer"
--description "Layer for ${{ github.event.repository.name }}"
--content "S3Bucket=${{ secrets.AWS_BUCKET }},S3Key=${{ github.event.repository.name }}-layer-${{ github.sha }}.zip"
--compatible-runtimes "python3.10"
--compatible-architectures "x86_64" > layer.json
- name: Update lambda function to match published layer
env:
FUNCTION_NAME: ${{ secrets.FUNCTION_NAME }}
run: aws lambda update-function-configuration
--function-name "${FUNCTION_NAME}"
--layers "$(jq -r '.LayerVersionArn' layer.json)"
- name: Wait for lambda to be updated
env:
FUNCTION_NAME: ${{ secrets.FUNCTION_NAME }}
run: aws lambda wait function-updated
--function-name $FUNCTION_NAME
--output text