-
-
Notifications
You must be signed in to change notification settings - Fork 2
72 lines (65 loc) · 2.32 KB
/
deploy-all-lambdas.yml
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
name: deploy lambda functions
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push: { branches: [main] }
jobs:
deploy-lambdas:
runs-on: ubuntu-latest
container: swift:5.10-amazonlinux2
env:
AWS_DEFAULT_REGION: eu-west-1
AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOYER_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOYER_ACCESS_SECRET_KEY }}
steps:
- name: Install additional dependencies and AWSCLI v2
run: |
yum -y install \
{libuuid,libicu,libedit,sqlite,python,ncurses,openssl}-devel \
libtool jq zip
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install
- name: Check out repository
# uses: actions/checkout@v3 Needs node 20 which amazonlinux2 doesn't have
run: |
git clone https://github.com/${{ github.repository }}
cd ${{ github.event.repository.name }}
git checkout ${{ github.sha }}
- name: Find package names
working-directory: ${{ github.event.repository.name }}
id: find_package_names
run: |
echo "names=$(
swift package describe --type json | \
jq -r '.targets[] |
select(
.type == "executable"
and
(.name | endswith("Lambda"))
).name' | \
tr '\n' ' '
)" >> $GITHUB_OUTPUT
- name: Build and package
working-directory: ${{ github.event.repository.name }}
run: |
mkdir zips
for name in ${{ steps.find_package_names.outputs.names }}; do
swift package archive \
--output-path ./zips \
--products "${name}"
aws s3api put-object \
--bucket penny-lambdas-store \
--key "${name}.zip" \
--body ./zips/${name}/${name}.zip
done
- name: Deploy
working-directory: ${{ github.event.repository.name }}
run: |
for name in ${{ steps.find_package_names.outputs.names }}; do
aws lambda update-function-code \
--function-name "${name}" \
--s3-bucket "penny-lambdas-store" \
--s3-key "${name}.zip"
done