refactor: better exception #8
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 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: DeployLambdaFunction | |
- 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 |