Skip to content

Commit

Permalink
chore:ci/cd
Browse files Browse the repository at this point in the history
  • Loading branch information
codernesty committed Aug 21, 2024
1 parent 608862a commit 0f7ae97
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 32 deletions.
28 changes: 1 addition & 27 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,4 @@ jobs:
# AWS CLI command to update the backend service in AWS App Runner
aws apprunner update-service \
--service-arn $(aws apprunner list-services --query "ServiceSummaryList[?ServiceName=='${{ secrets.APP_RUNNER_SERVICE_NAME_BACKEND }}'].ServiceArn | [0]" --output text) \
--source-configuration SourceCodeRepository={"RepositoryUrl": "${{ secrets.REPOSITORY_URL_BACKEND }}", "SourceCodeVersion": {"Type": "BRANCH", "Value": "master"}}
# Job for deploying the frontend service
deploy-frontend:
name: Deploy Frontend to AWS App Runner
runs-on: ubuntu-latest # Run on the latest version of Ubuntu

steps:
# Step 1: Checkout the code from the repository
- name: Checkout code
uses: actions/checkout@v3 # GitHub Action to checkout the code

# Step 2: Set up AWS CLI with necessary credentials
- name: Set up AWS CLI
uses: aws-actions/configure-aws-credentials@v2 # GitHub Action to configure AWS credentials
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} # AWS Access Key ID stored as a GitHub secret
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} # AWS Secret Access Key stored as a GitHub secret
aws-region: ${{ secrets.AWS_REGION }} # AWS Region stored as a GitHub secret

# Step 3: Deploy the frontend service to AWS App Runner
- name: Deploy Frontend
run: |
# AWS CLI command to update the frontend service in AWS App Runner
aws apprunner update-service \
--service-arn $(aws apprunner list-services --query "ServiceSummaryList[?ServiceName=='${{ secrets.APP_RUNNER_SERVICE_NAME_FRONTEND }}'].ServiceArn | [0]" --output text) \
--source-configuration SourceCodeRepository={"RepositoryUrl": "${{ secrets.REPOSITORY_URL_FRONTEND }}", "SourceCodeVersion": {"Type": "BRANCH", "Value": "master"}}
--source-configuration SourceCodeRepository={"RepositoryUrl": "${{ secrets.REPOSITORY_URL_BACKEND }}", "SourceCodeVersion": {"Type": "BRANCH", "Value": "master"}}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ all:
# ------------------------ #

start-backend:
@fastapi dev 'linguaphoto/main.py' --port 8080
@python 'linguaphoto/main.py'

start-frontend:
@cd frontend && npm start
Expand Down
5 changes: 3 additions & 2 deletions linguaphoto/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Defines the main entrypoint for the FastAPI app."""

from fastapi import FastAPI, Request, status
import uvicorn
from fastapi import FastAPI, Request, status
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse

Expand Down Expand Up @@ -29,6 +29,7 @@ async def value_error_exception_handler(request: Request, exc: ValueError) -> JS
async def root() -> dict[str, str]:
return {"message": "Hello, World!"}


if __name__ == "__main__":
print("Starting webserver...")
uvicorn.run(app, port=8080, host='0.0.0.0')
uvicorn.run(app, port=8080, host="0.0.0.0")
4 changes: 2 additions & 2 deletions linguaphoto/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ s3fs
# Types
types-requests

# AWS
localstack
# # AWS
# localstack

0 comments on commit 0f7ae97

Please sign in to comment.