This repository was archived by the owner on Mar 24, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
221 lines (202 loc) · 5.32 KB
/
Copy pathdeploy-fe.yml
File metadata and controls
221 lines (202 loc) · 5.32 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#
# This workflow runs on push events and pull_requests of the main branch (i.e. PR merges) which
# contain changes to the frontend/** files.
#
# Web app is built and deployed to AWS S3 Bucket.
#
name: deploy-fe
on:
push:
branches:
- main
paths:
- frontend/**
pull_request:
branches:
- main
paths:
- frontend/**
jobs:
build:
runs-on: ubuntu-latest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
#
# Checkout the repository.
#
- uses: actions/checkout@v3
id: checkout
#
# Cache files in ./frontend
#
- name: Cache
uses: actions/cache@v3
id: use-cache
with:
path: |
frontend/node_modules/
frontend/.eslintcache
frontend/.stylelintcache
frontend/**/.cache
frontend/apps/**/node_modules/
frontend/packages/**/node_modules/
~/.cache/Cypress
key: develop-fe-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
develop-fe-
#
# Install yq library for conversion yaml-to-json
#
- name: Get yq libary
id: yaml-library
uses: mikefarah/yq@master
#
# Install dependencies and build the app
#
- name: Build React App
id: build-project
run: yarn install --frozen-lockfile && yarn bootstrap && yarn build
working-directory: ./frontend
#
# Upload the build as artifact
#
- name: Artifacts
id: upload-artifact-build
uses: actions/upload-artifact@v3
with:
name: artifact-fe
path: |
frontend/apps/web/dist/
frontend/packages/**/dist/
#
# Notify on slack if there is a failure
#
- uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: ${{ secrets.SLACK_CHANNEL }}
if: failure()
test:
needs: [build]
runs-on: ubuntu-latest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
#
# Checkout the repository.
#
- uses: actions/checkout@v3
id: checkout
#
# Cache files in ./frontend
#
- name: Cache
uses: actions/cache@v3
id: cache
with:
path: |
frontend/node_modules/
frontend/.eslintcache
frontend/.stylelintcache
frontend/**/.cache
frontend/apps/**/node_modules/
frontend/packages/**/node_modules/
~/.cache/Cypress
key: develop-fe-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
develop-fe-
#
# Run generate scripts
#
- name: Generate routes and behaviors
id: generate-data
run: yarn prebuild
working-directory: ./frontend/apps/web
#
# Run lint
#
- name: Lint
id: lint
run: NODE=production yarn lint
working-directory: ./frontend
#
# Run tests
#
- name: Test
id: unit-tests
run: yarn test
working-directory: ./frontend
#
# Download artifact for e2e testing
#
- uses: actions/download-artifact@v3
id: download-artifact
with:
name: artifact-fe
#
# Run e2e tests
#
- name: E2E test
id: e2e-tests
run: mv ../../../apps/web/* ./ && ./node_modules/.bin/cypress install && yarn ci:e2e
working-directory: ./frontend/apps/web
#
# Upload cypress video to artifact
#
- name: Artifacts
uses: actions/upload-artifact@v3
id: upload-artifact-cypress
with:
name: artifact-fe
path: |
frontend/apps/web/cypress/videos
frontend/apps/web/cypress/screenshots
#
# Notify if there is a failure or if this is a pull_request event
#
- uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: ${{ secrets.SLACK_CHANNEL }}
if: ${{ github.event_name == 'pull_request' || failure() }}
deploy:
if: ${{ github.event_name != 'pull_request' }}
needs: [build, test]
runs-on: ubuntu-latest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
#
# Configure AWS credentials
#
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
id: init-aws
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
#
# Download the artifact
#
- uses: actions/download-artifact@v3
with:
name: artifact-fe
#
# Upload the app on S3 bucket
#
- name: Deploy app build to S3 bucket
id: deploy
run: aws s3 sync ./apps/web/dist/ s3://fc-fe-dev --cache-control "max-age=120000" --delete
#
# Notify the status of deploy on slack
#
- uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: ${{ secrets.SLACK_CHANNEL }}
if: always()