Skip to content

Commit

Permalink
Added deploy.yml to us github actions to deploy container image to la…
Browse files Browse the repository at this point in the history
…mbda
  • Loading branch information
dbodduluru committed Apr 5, 2024
1 parent 1bca9d2 commit 0ed4171
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
47 changes: 47 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Deploy to AWS Lambda

on:
push:
branches:
- main
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: arn:aws:iam::590312749310:role/github-actions-role
role-session-name: lambda-gh-actions
aws-region: ap-southeast-2

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build Docker image
run: docker build -t predictive_maintenance .

- name: Tag Docker image
run: docker tag predictive_maintenance:latest 590312749310.dkr.ecr.ap-southeast-2.amazonaws.com/predictive-maintenance:latest

- name: Push Docker image to ECR
run: docker push 590312749310.dkr.ecr.ap-southeast-2.amazonaws.com/predictive-maintenance:latest

- name: update lambda function
run: |
aws lambda update-function-code \
--function-name predictive_maintenance \
--image-uri 590312749310.dkr.ecr.ap-southeast-2.amazonaws.com/predictive-maintenance:latest
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@app.get("/")
async def root():
return {"message": "Hello World!"}
return {"message": "Hello World! testing ci/cd v1"}

@app.post("/predict")
async def predict(features: List[float]):
Expand Down

0 comments on commit 0ed4171

Please sign in to comment.