-
Notifications
You must be signed in to change notification settings - Fork 9
262 lines (228 loc) · 9.73 KB
/
ci.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
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: CI
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
env:
IMAGE_TAG: ${{ github.sha }}
DOCKER_BUILDKIT: 1
jobs:
frontend:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- uses: actions/setup-node@v4
with:
node-version: '18'
- name: NPM Cache
uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-
- name: Typecheck
run: |
make typecheck
- name: Build Docker images
run: |
make IMAGE_TAG=${IMAGE_TAG} TARGET=prod build
make IMAGE_TAG=${IMAGE_TAG} TARGET=dev build
- name: Lint
run: |
make lint
- name: Test
run: |
make IMAGE_TAG=${IMAGE_TAG} test
- name: Ingestion smoke test
run: |
make IMAGE_TAG=${IMAGE_TAG} INGEST_ONLY=non-existent-group INGEST_DEBUG=true ingest-evaluations
- name: Server smoke test
run: |
.github/smoke-test.sh
- name: Backstop test
run: |
make IMAGE_TAG=${IMAGE_TAG} backstop-test
- name: Taiko
run: |
make taiko
- name: Push Image to GHCR
if: github.ref == 'refs/heads/main'
run: |
echo "${GHCR_PASSWORD}" | docker login ghcr.io --username "${GHCR_USERNAME}" --password-stdin
docker tag sciety/sciety:${IMAGE_TAG} ghcr.io/sciety/sciety:${IMAGE_TAG}
docker push ghcr.io/sciety/sciety:${IMAGE_TAG}
env:
GHCR_USERNAME: ${{ github.actor }}
GHCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to staging
if: github.ref == 'refs/heads/main'
run: |
aws --region=us-east-1 eks update-kubeconfig --name libero-eks--franklin
helm repo add bitnami https://charts.bitnami.com/bitnami
helm dependency build helm/sciety
helm upgrade -i sciety--staging \
--set images.frontend.tag=${IMAGE_TAG} \
--set hostname=staging.sciety.org \
--set crossrefApiBearerToken=${CROSSREF_API_BEARER_TOKEN} \
--set-string experimentEnabled="true" \
--set appSecret=${APP_SECRET} \
--set appCache=redis \
--set auth0ClientId=${AUTH0_CLIENT_ID_STAGING} \
--set auth0ClientSecret=${AUTH0_CLIENT_SECRET_STAGING} \
--set auth0Domain='sciety-staging.eu.auth0.com' \
--set auth0CallbackUrl='https://staging.sciety.org/auth0/callback' \
--set postgresqlSecretName=hive-staging-rds-postgres \
--set googleTagManagerId='GTM-NX7CQB4' \
--set ingestionAuthBearerToken=${SCIETY_TEAM_API_BEARER_TOKEN} \
--set prelightsFeedKey=${PRELIGHTS_FEED_KEY} \
--set healthchecksPingKey=${HEALTHCHECKS_PING_KEY} \
--wait \
helm/sciety
env:
APP_SECRET: ${{ secrets.APP_SECRET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CROSSREF_API_BEARER_TOKEN: ${{ secrets.CROSSREF_API_BEARER_TOKEN }}
SCIETY_TEAM_API_BEARER_TOKEN: ${{ secrets.SCIETY_TEAM_API_BEARER_TOKEN }}
PRELIGHTS_FEED_KEY: ${{ secrets.PRELIGHTS_FEED_KEY }}
AUTH0_CLIENT_ID_STAGING: ${{ secrets.AUTH0_CLIENT_ID_STAGING }}
AUTH0_CLIENT_SECRET_STAGING: ${{ secrets.AUTH0_CLIENT_SECRET_STAGING }}
HEALTHCHECKS_PING_KEY: ${{ secrets.HEALTHCHECKS_PING_KEY }}
- name: Deploy to prod
if: github.ref == 'refs/heads/main'
run: |
aws --region=us-east-1 eks update-kubeconfig --name libero-eks--franklin
helm repo add bitnami https://charts.bitnami.com/bitnami
helm dependency build helm/sciety
helm upgrade -i sciety--prod \
--set-string allowSiteCrawlers=true \
--set images.frontend.tag=${IMAGE_TAG} \
--set hostname=sciety.org \
--set fathomSiteId='DBULFPXG' \
--set googleTagManagerId='GTM-NX7CQB4' \
--set crossrefApiBearerToken=${CROSSREF_API_BEARER_TOKEN} \
--set appSecret=${APP_SECRET} \
--set appCache=redis \
--set auth0ClientId=${AUTH0_CLIENT_ID} \
--set auth0ClientSecret=${AUTH0_CLIENT_SECRET} \
--set auth0Domain='sciety.eu.auth0.com' \
--set auth0CallbackUrl='https://sciety.org/auth0/callback' \
--set postgresqlSecretName=hive-prod-rds-postgres \
--set ingestionAuthBearerToken=${SCIETY_TEAM_API_BEARER_TOKEN} \
--set prelightsFeedKey=${PRELIGHTS_FEED_KEY} \
--set healthchecksPingKey=${HEALTHCHECKS_PING_KEY} \
--wait \
helm/sciety
env:
APP_SECRET: ${{ secrets.APP_SECRET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CROSSREF_API_BEARER_TOKEN: ${{ secrets.CROSSREF_API_BEARER_TOKEN }}
SCIETY_TEAM_API_BEARER_TOKEN: ${{ secrets.SCIETY_TEAM_API_BEARER_TOKEN }}
PRELIGHTS_FEED_KEY: ${{ secrets.PRELIGHTS_FEED_KEY }}
AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }}
AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }}
HEALTHCHECKS_PING_KEY: ${{ secrets.HEALTHCHECKS_PING_KEY }}
- name: Notify Slack
if: failure() && github.ref == 'refs/heads/main'
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
with:
channel: sciety-commits
status: FAILED
color: danger
- name: Archive Taiko screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: feature-test-screenshots
path: feature-test/screenshots
- name: Archive Backstop screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: backstop_data
path: backstop_data
- name: Checkout deployment
if: github.ref == 'refs/heads/main'
uses: actions/checkout@v4
with:
repository: 'sciety/deployment'
path: 'deployment'
ssh-key: '${{ secrets.SCIETY_DEPLOYMENT_REPO_WRITE_ACCESS_SSH_KEY }}'
- name: Update demo deployment to latest version
if: github.ref == 'refs/heads/main'
run: |
cd deployment
TAG=${IMAGE_TAG} yq -i '.spec.values.images.frontend.tag = strenv(TAG)' manifests/sciety--demo.yaml
git add .
git config user.email "team@sciety.org"
git config user.name "Deployment update bot"
git commit -m "Update demo deployment to ${IMAGE_TAG}"
git push
automerge:
needs: frontend
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
permissions:
contents: write
pull-requests: write
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: auto-merge patch updates to @types/*
if: startsWith(steps.metadata.outputs.dependency-names, '@types') && steps.metadata.outputs.update-type == 'version-update:semver-patch'
run: gh pr merge --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: auto-merge all updates to @typescript-eslint/*
if: startsWith(steps.metadata.outputs.dependency-names, '@typescript-eslint')
run: gh pr merge --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: auto-merge all updates to eslint*
if: startsWith(steps.metadata.outputs.dependency-names, 'eslint')
run: gh pr merge --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: auto-merge all updates to @swc/*
if: startsWith(steps.metadata.outputs.dependency-names, '@swc')
run: gh pr merge --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: auto-merge all updates to dependency-cruiser
if: startsWith(steps.metadata.outputs.dependency-names, 'dependency-cruiser')
run: gh pr merge --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: auto-merge minor and patch updates to sass*
if: startsWith(steps.metadata.outputs.dependency-names, 'sass') && steps.metadata.outputs.update-type == 'version-update:semver-minor'
run: gh pr merge --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: auto-merge patch updates to backstopjs
if: startsWith(steps.metadata.outputs.dependency-names, 'backstopjs') && steps.metadata.outputs.update-type == 'version-update:semver-patch'
run: gh pr merge --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: auto-merge patch updates to browserslist
if: startsWith(steps.metadata.outputs.dependency-names, 'browserslist') && steps.metadata.outputs.update-type == 'version-update:semver-minor'
run: gh pr merge --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}