Final Commit last #11
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 to AWS Lambda | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the code | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
# Step 2: Install Node.js (Updated to version 18) | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18' | |
# Step 3: Install Serverless Framework | |
- name: Install Serverless | |
run: npm install -g serverless | |
# Step 4: Configure AWS credentials using GitHub secrets | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
# Step 5: Deploy the Lambda function using Serverless Framework | |
- name: Deploy Lambda function | |
run: | | |
start_time=$(date +%s) | |
serverless deploy | |
end_time=$(date +%s) | |
echo "Deployment time: $((end_time - start_time)) seconds" | |
env: | |
SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }} | |