Skip to content

Commit

Permalink
chore:sigle_app_runner_setting
Browse files Browse the repository at this point in the history
  • Loading branch information
codernesty committed Aug 19, 2024
1 parent 28fed29 commit 79acd40
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 35 deletions.
46 changes: 11 additions & 35 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,14 @@
name: Deploy to AWS App Runner

# Trigger this workflow on any push to the 'main' branch
# Trigger this workflow on any push to the 'master' branch
on:
push:
branches:
- master

jobs:
# Job for deploying the backend service
deploy-backend:
name: Deploy Backend 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: us-east-1 # AWS Region stored as a GitHub secret

# Step 3: Deploy the backend service to AWS App Runner
- name: Deploy Backend
run: |
# 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
deploy:
name: Deploy Fullstack App to AWS App Runner
runs-on: ubuntu-latest # Run on the latest version of Ubuntu

steps:
Expand All @@ -51,10 +24,13 @@ jobs:
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
# Step 3: Deploy the combined service to AWS App Runner
- name: Deploy Fullstack App
run: |
# AWS CLI command to update the frontend service in AWS App Runner
# Get the App Runner service ARN
SERVICE_ARN=$(aws apprunner list-services --query "ServiceSummaryList[?ServiceName=='${{ secrets.APP_RUNNER_SERVICE_NAME }}'].ServiceArn | [0]" --output text)
# Deploy the code to the App Runner service
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"}}
--service-arn $SERVICE_ARN \
--source-configuration SourceCodeRepository={"RepositoryUrl": "${{ secrets.REPOSITORY_URL }}", "SourceCodeVersion": {"Type": "BRANCH", "Value": "master"}}
14 changes: 14 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Navigate to the frontend, install dependencies, and build it
cd frontend
npm install
npm run build

# Start serving the frontend (you might use a static server like serve)
npx serve -s build &

# Navigate to the backend, install dependencies, and start the server
cd ../linguaphoto
pip install -r requirements.txt
fastapi run --port 8080

0 comments on commit 79acd40

Please sign in to comment.