Merge branch 'main' of https://github.com/vapor/penny-bot #523
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:6.0-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 |