-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (43 loc) · 1.34 KB
/
lambda_deployment.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
name: Deploy Lambda Function
on:
push:
branches:
- main
paths:
- lambda/**
- .github/workflows/lambda_deployment.yml
workflow_dispatch:
permissions:
id-token: write # Required for requesting the Json Web Token (JWT)
contents: read # Required for actions/checkout
jobs:
update-lambda:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
id: checkout-code
uses: actions/checkout@v4
- name: Configure AWS credentials from OIDC
id: configure-aws-credentials
uses: aws-actions/configure-aws-credentials@v4
with:
audience: sts.amazonaws.com
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_GITHUB_ACTIONS_ROLE_ARN }}
role-session-name: deploy-lambda
- name: Package and Zip Lambda function
id: package-zip-lambda
run: |
cd lambda
chmod +x ./package_and_zip.sh
./package_and_zip.sh
- name: Upload to S3
id: upload-s3
run: aws s3 cp ./lambda/lambda_function.zip s3://${{ secrets.S3_BUCKET }}/lambda_function.zip
- name: Update Lambda function code
id: update-lambda
run: |
aws lambda update-function-code \
--function-name ${{ secrets.LAMBDA_FUNCTION }} \
--s3-bucket ${{ secrets.S3_BUCKET }} \
--s3-key lambda_function.zip