-
Notifications
You must be signed in to change notification settings - Fork 3
172 lines (149 loc) · 5.6 KB
/
frontend_ci_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
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
name: Frontend CI/CD
on:
push:
paths:
- 'frontend/**'
- ".github/workflows/frontend*"
workflow_dispatch:
env:
NODE_ENV: production
PORT: 3000
jobs:
e2e-chrome:
name: Running frontend tests on Chrome
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
fail-fast: false
defaults:
run:
working-directory: ${{github.workspace}}/frontend
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: 'frontend/.nvmrc'
cache: 'yarn'
cache-dependency-path: frontend/yarn.lock
- 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: Install dependencies
run: yarn install --production=false --frozen-lockfile
- name: Cypress running on Chrome
uses: cypress-io/github-action@v5
with:
working-directory: frontend
install: false
build: yarn build
start: yarn start
headed: false
browser: chrome
wait-on: http://localhost:3000
config-file: cypress.config.js
env:
NEXT_PUBLIC_API_HOST: ${{ secrets.NEXT_PUBLIC_API_HOST }}
NEXT_PUBLIC_GOOGLE_ANALYTICS: ${{ secrets.NEXT_PUBLIC_GOOGLE_ANALYTICS }}
NEXT_PUBLIC_TRANSIFEX_TOKEN: ${{ secrets.NEXT_PUBLIC_TRANSIFEX_TOKEN }}
NEXT_PUBLIC_TRANSIFEX_SECRET: ${{ secrets.NEXT_PUBLIC_TRANSIFEX_SECRET }}
NEXT_PUBLIC_GOOGLE_API_KEY: ${{ secrets.NEXT_PUBLIC_GOOGLE_API_KEY }}
CI: false
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: ${{github.workspace}}/frontend/cypress/screenshots
e2e-firefox:
name: Running frontend tests on Firefox
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
fail-fast: false
defaults:
run:
working-directory: ${{github.workspace}}/frontend
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: 'frontend/.nvmrc'
cache: 'yarn'
cache-dependency-path: frontend/yarn.lock
- 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: Install dependencies
run: yarn install --production=false --frozen-lockfile
- name: Cypress running on Firefox
uses: cypress-io/github-action@v5
with:
working-directory: frontend
install: false
build: yarn build
start: yarn start
headed: false
browser: firefox
wait-on: http://localhost:3000
config-file: cypress.config.js
env:
NEXT_PUBLIC_API_HOST: ${{ secrets.NEXT_PUBLIC_API_HOST }}
NEXT_PUBLIC_GOOGLE_ANALYTICS: ${{ secrets.NEXT_PUBLIC_GOOGLE_ANALYTICS }}
NEXT_PUBLIC_TRANSIFEX_TOKEN: ${{ secrets.NEXT_PUBLIC_TRANSIFEX_TOKEN }}
NEXT_PUBLIC_TRANSIFEX_SECRET: ${{ secrets.NEXT_PUBLIC_TRANSIFEX_SECRET }}
NEXT_PUBLIC_GOOGLE_API_KEY: ${{ secrets.NEXT_PUBLIC_GOOGLE_API_KEY }}
CI: false
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: ${{github.workspace}}/frontend/cypress/screenshots
deploy:
name: Deploy frontend
if: (github.head_ref || github.ref_name) == 'develop' || (github.head_ref || github.ref_name) == 'master'
runs-on: ubuntu-22.04
timeout-minutes: 30
needs: [e2e-chrome, e2e-firefox]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install ruby + gems
uses: ruby/setup-ruby@v1
with:
# ruby-version: 3.2.1 # Not needed with a .ruby-version file
bundler-cache: true
working-directory: frontend
- name: Extract branch name
shell: bash
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >>$GITHUB_OUTPUT
id: extract_branch
- name: Deploy using capistrano
uses: miloserdow/capistrano-deploy@v3
with:
working-directory: frontend
target: ${{ steps.extract_branch.outputs.branch == 'master' && 'production' || 'staging' }}
deploy_key: ${{ secrets.DEPLOY_KEY_PASSWORD }}
enc_rsa_key_val: ${{ secrets.DEPLOY_ENC_KEY }}