-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (91 loc) · 2.82 KB
/
cd.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: CD
on:
push:
# NOTE: Don't add other branches
branches:
- develop
jobs:
test_build:
if: github.event_name == 'push'
name: Run Tests + Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Run yarn install
run: yarn install
- name: Build + Test
run: yarn export
env:
NODE_OPTIONS: --max_old_space_size=4096
NEXT_PRIVATE_STANDALONE: true
- name: Upload GH artifacts
uses: actions/upload-pages-artifact@v1
with:
path: out/
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: out/
name: client-build
staging_deploy:
name: Deploy (STAGING)
needs: test_build
runs-on: ubuntu-latest
if: github.event_name == 'push'
permissions:
contents: write
id-token: write
pages: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages 🚀
id: deployment
uses: actions/deploy-pages@v2
prod_deploy:
name: Deploy (PROD)
needs: [test_build, staging_deploy]
runs-on: ubuntu-latest
if: github.event_name == 'push'
environment:
name: prod
url: https://togglecorp.com
steps:
- uses: actions/download-artifact@v3
with:
name: client-build
path: ./out
# Copy build to S3
- name: S3 Sync
uses: jakejarvis/s3-sync-action@master
with:
args: --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_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: './out'
# Invalidate Cloudfront (this action)
- name: Cloudfront Invalidate
uses: chetan/invalidate-cloudfront-action@master
env:
DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
PATHS: '/*'