-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (68 loc) · 2.54 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
73
74
75
76
77
78
name: Deploy to S3 and CloudFront
on:
push:
branches:
- main
- develop
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# 1. Check out the repository
- name: Checkout Code
uses: actions/checkout@v3
# 2. Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 23 # Update this if your app uses a different version
# 3. Install dependencies
- name: Install Dependencies
run: yarn install
# 4. Build the app
- name: Build React App
run: yarn build
# 5. Deploy to Production S3 Bucket (main branch)
- name: Deploy to Production
if: github.ref == 'refs/heads/main'
uses: jakejarvis/s3-sync-action@v0.5.1
with:
args: --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_PROD_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: dist
# 6. Deploy to Development S3 Bucket (develop branch)
- name: Deploy to Development
if: github.ref == 'refs/heads/develop'
uses: jakejarvis/s3-sync-action@v0.5.1
with:
args: --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_DEV_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: dist
# 7. Invalidate CloudFront Cache (Production)
- name: Invalidate CloudFront Cache (Production)
if: github.ref == 'refs/heads/main'
uses: chetan/invalidate-cloudfront-action@v1
env:
DISTRIBUTION: ${{ secrets.AWS_PROD_CLOUDFRONT_DISTRIBUTION_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
PATHS: '/*'
# 8. Invalidate CloudFront Cache (Development)
- name: Invalidate CloudFront Cache (Development)
if: github.ref == 'refs/heads/develop'
uses: chetan/invalidate-cloudfront-action@v1
env:
DISTRIBUTION: ${{ secrets.AWS_DEV_CLOUDFRONT_DISTRIBUTION_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
PATHS: '/*'