Skip to content

Restructure the folder and add terraform files to the frontend folder #19

Restructure the folder and add terraform files to the frontend folder

Restructure the folder and add terraform files to the frontend folder #19

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches:
- main # Trigger CI/CD for every push to the 'main' branch
pull_request:
branches:
- main # Trigger CI/CD for pull requests to 'main' branch
jobs:
# Job for Backend (Lambda and API)
backend:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.8
- name: Install Backend Dependencies
run: |
cd backend
pip install -r requirements.txt
- name: Run Backend Tests
run: |
cd backend
pytest
- name: Deploy Backend to AWS (SAM)
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
cd backend
sam build
sam deploy --no-confirm-changeset --stack-name my-stack --capabilities CAPABILITY_IAM
# Job for Frontend (Web App)
frontend:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Node.js 16
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install Frontend Dependencies
run: |
cd frontend
npm install
- name: Build Frontend
run: |
cd frontend
npm run build
- name: Deploy Frontend to S3
env:
AWS_ACCESS_KEY_ID: ${ secrets.AWS_ACCESS_KEY_ID }
AWS_SECRET_ACCESS_KEY: ${ secrets.AWS_SECRET_ACCESS_KEY }
run: |
cd frontend
aws s3 sync build/ s3://your-bucket-name --delete
aws cloudfront create-invalidation --distribution-id your-cloudfront-id --paths "/*"