Enable test route in index.mjs #41
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: Zip and Update Lambda Function | |
on: | |
push: | |
branches: [main] # This triggers the workflow on pushes to the main branch | |
env: | |
AWS_REGION: "us-east-1" # AWS region | |
S3_BUCKET: "wavewise" # S3 bucket name | |
LAMBDA_FUNCTION_NAME: "wavewise-backend" # Lambda function name | |
jobs: | |
deploy: | |
name: Deploy to S3 and Update Lambda Function | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials from IAM role | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::851725484938:role/github-aws # ARN of the IAM role to assume | |
aws-region: ${{ env.AWS_REGION }} | |
role-session-name: GitHubActionsDeploymentSession | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "21.x" # Using a valid LTS version of Node.js | |
- name: Install production dependencies with Yarn | |
run: yarn install --frozen-lockfile --production | |
- name: Zip project directory excluding development files | |
run: zip -r wavewise-backend.zip . -x "*.git*" "*tests*" "*docs*" | |
- name: Upload zip to S3 | |
run: aws s3 cp wavewise-backend.zip s3://${{ env.S3_BUCKET }}/${{ env.LAMBDA_FUNCTION_NAME }}.zip | |
- name: Update Lambda function code from S3 | |
run: | | |
aws lambda update-function-code \ | |
--function-name ${{ env.LAMBDA_FUNCTION_NAME }} \ | |
--s3-bucket ${{ env.S3_BUCKET }} \ | |
--s3-key ${{ env.LAMBDA_FUNCTION_NAME }}.zip |