-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (61 loc) · 1.81 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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 "/*"