-
Notifications
You must be signed in to change notification settings - Fork 4
462 lines (393 loc) · 15.2 KB
/
Copy pathpush.yml
File metadata and controls
462 lines (393 loc) · 15.2 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
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
name: "Push"
on:
push:
branches:
- main
pull_request:
release:
types:
- published
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
permissions: {}
jobs:
build:
name: Build and cache Docker image
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
steps:
- name: "Checkout"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
- name: "Login to Docker Hub"
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
continue-on-error: true
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker Image
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: .
target: dev
push: false
tags: gmri/neracoos-mariners-dashboard:latest
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=docker,dest=/tmp/myimage.tar
- name: Upload dev image artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dev-image
path: /tmp/myimage.tar
retention-days: 1
build-prod:
name: Build production Docker image
runs-on: ubuntu-24.04
needs: build
timeout-minutes: 10
permissions:
contents: read
steps:
- name: "Checkout"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
- name: Download dev image artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: dev-image
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/myimage.tar
docker image ls -a
- name: Build Docker Image
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: .
target: runner
push: false
tags: gmri/neracoos-mariners-dashboard:latest
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=docker,dest=/tmp/prodimage.tar
- name: Upload production image artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: prod-image
path: /tmp/prodimage.tar
retention-days: 1
unit_tests:
name: Unit tests, typecheck and coverage
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
steps:
- name: "Checkout"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: mise action
uses: jdx/mise-action@7e36c90d9ab29c415a2384db3006f3ec8a8cc654 # v4.2.4
- name: Cache node modules
id: cache-npm
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm install --frozen-lockfile
- name: Install Playwright
run: npx playwright install chromium
- name: Run unit and Storybook tests and coverage
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
if: env.CODACY_PROJECT_TOKEN != null
run: npm run test:coverage
- name: Codacy Coverage Reporter
if: env.CODACY_PROJECT_TOKEN != null
uses: codacy/codacy-coverage-reporter-action@89d6c85cfafaec52c72b6c5e8b2878d33104c699 # v1.3.0
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ./coverage/lcov.info
- name: Run unit and Storybook test (and skip coverage if no project token secret)
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
if: env.CODACY_PROJECT_TOKEN == null
run: npm run test-ci
- name: npm run Build
run: npm run build
- name: Build Storybook Pages
run: npm run build-storybook
# - name: Cache Storybook Build
# uses: actions/cache@v6.1.0
# with:
# path: /tmp/storybook-public/
# key: mariners-dashboard-storybook-${{ github.sha }}
# - name: Copy Storybook Build to cache directory
# run: |
# rm -rf /tmp/storybook-public
# cp -r storybook-public /tmp/storybook-public
playwright:
name: Playwright integration tests
runs-on: ubuntu-24.04
needs: build-prod
timeout-minutes: 30
permissions:
contents: read
env:
# Playwright uses this env var for the browser install path. See:
# https://playwright.dev/docs/ci#directories-to-cache
# It makes most sense to default this to something cross-platform
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/ms-playwright
steps:
- name: "Checkout"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "22"
cache: npm
- name: Download production image artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: prod-image
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/prodimage.tar
docker image ls -a
- name: Start container
run: docker compose up -d client
- run: npm install --frozen-lockfile
# Use Playwright version as part of the cache key
# AFAIK this is a x-platform way to get your installed Playwright version.
# Be sure to be diligent in specifying ^, ~, or locked versions.
- run: |
echo "PLAYWRIGHT_VERSION=$(node -e "process.stdout.write(require('@playwright/test/package.json').version)")" >> $GITHUB_OUTPUT
id: playwright-version
# Cache action
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: playwright-cache
with:
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.PLAYWRIGHT_VERSION }}
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
# This command should work and only be ran on cold cache
- run: npx playwright install
if: steps.playwright-cache.outputs.cache-hit != 'true'
- name: Wait for container to become available
run: npx wait-on http://localhost:3000
timeout-minutes: 1
- name: Run Playwright tests
run: npm run test:e2e
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
# pages:
# name: Deploy Storybook to Github Pages on version tag
# runs-on: ubuntu-24.04
# needs: [unit_tests, playwright]
# timeout-minutes: 10
# if: |
# github.repository == 'gulfofmaine/Neracoos-1-Buoy-App'
# && contains(github.ref, 'refs/tags/v')
# steps:
# - name: "Checkout"
# uses: actions/checkout@v7.0.0
# - name: Cache Storybook Build
# uses: actions/cache@v6.1.0
# with:
# path: /tmp/storybook-public/
# key: mariners-dashboard-storybook-${{ github.sha }}
# - name: Deploy Storybook to Github Pages 🚀
# uses: JamesIves/github-pages-deploy-action@v4.4.3
# with:
# branch: gh-pages
# folder: /tmp/storybook-public/
push_image:
name: Build and push tagged image to Docker Hub
runs-on: ubuntu-24.04
needs: [unit_tests, playwright]
timeout-minutes: 20
environment: Deploy with ArgoCD
outputs:
tag: ${{ steps.tagName.outputs.tag }}
image_digest: ${{ steps.push.outputs.digest }}
if: |
github.repository == 'gulfofmaine/Neracoos-1-Buoy-App'
&& github.event_name == 'release'
permissions:
contents: read
steps:
- name: "Checkout"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
- name: Download production image artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: prod-image
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/prodimage.tar
docker image ls -a
- name: "Login to Docker Hub"
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get tag name
id: tagName
run: echo "tag=${GITHUB_EVENT_RELEASE_TAG_NAME}" >> $GITHUB_OUTPUT
env:
GITHUB_EVENT_RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
- name: Build and push Docker Image
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
id: push
with:
context: .
push: true
tags: gmri/neracoos-mariners-dashboard:${{ steps.tagName.outputs.tag }}
no-cache: true
build-args: |
NEXT_PUBLIC_ERDDAP_SERVICE=https://buoybarn.neracoos.org
NEXT_PUBLIC_SENTRY_DSN=${{ secrets.SENTRY_DSN_PROD }}
- name: Copy Next.JS sourcemaps
run: docker run -v $PWD:/opt/mount --rm --entrypoint cp gmri/neracoos-mariners-dashboard -r /app/.next /opt/mount/next-build
- name: Create Sentry Release
uses: getsentry/action-release@ff07929a6537bac57790c3451cf4d364aca38528 # v3.7.0
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
environment: production
release: ${{ steps.tagName.outputs.tag }}
sourcemaps: ./next-build
inject: false
release:
name: Notify deploy repo of new release
needs: [push_image]
uses: gulfofmaine/odp-releaser/.github/workflows/notify.yml@52b11709c1fb73c142b24b62ce7a11ecb37f7da3
permissions:
contents: read
pull-requests: read # ODP Releaser wants to figure out who made a PR
if: |
github.repository == 'gulfofmaine/Neracoos-1-Buoy-App'
&& github.event_name == 'release'
with:
image_name: gmri/neracoos-mariners-dashboard
tag: ${{ needs.push_image.outputs.tag }}
digest: ${{ needs.push_image.outputs.image_digest }}
environment: notify # optional gate
# deploy_targets_path: .github/deploy_targets.yaml # optional
verbosity: 3 # optional, default
secrets:
dispatch_app_id: ${{ secrets.GULFOFMAINE_ODP_DISPATCH_APP_ID }}
dispatch_app_private_key: ${{ secrets.GULFOFMAINE_ODP_DISPATCH_PRIVATE_KEY }}
push_dev_image:
name: Build and push dev image to Docker Hub
runs-on: ubuntu-24.04
needs: [unit_tests, playwright]
timeout-minutes: 20
environment: Deploy with ArgoCD
outputs:
tag: ${{ steps.tagName.outputs.tag }}
image_digest: ${{ steps.push.outputs.digest }}
if: |
github.repository == 'gulfofmaine/Neracoos-1-Buoy-App'
&& github.ref == 'refs/heads/main'
permissions:
contents: read
steps:
- name: "Checkout"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
- name: Download production image artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: prod-image
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/prodimage.tar
docker image ls -a
- name: "Login to Docker Hub"
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get tag name
id: tagName
run: echo "tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build and push Docker Image
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
id: push
with:
context: .
push: true
tags: gmri/neracoos-mariners-dashboard:${{ steps.tagName.outputs.tag }}
cache-from: type=local,src=/tmp/.buildx-cache
build-args: |
NEXT_PUBLIC_ERDDAP_SERVICE=https://buoybarn.neracoos.org
NEXT_PUBLIC_SENTRY_DSN=${{ secrets.SENTRY_DSN_DEV }}
- name: Copy Next.JS sourcemaps
run: docker run -v $PWD:/opt/mount --rm --entrypoint cp gmri/neracoos-mariners-dashboard -r /app/.next /opt/mount/next-build
- name: Create Sentry Release
uses: getsentry/action-release@ff07929a6537bac57790c3451cf4d364aca38528 # v3.7.0
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
environment: dev
release: ${{ steps.tagName.outputs.tag }}
sourcemaps: ./next-build
inject: false
release_dev:
name: Notify deploy repo of new dev
needs: [push_dev_image]
uses: gulfofmaine/odp-releaser/.github/workflows/notify.yml@fef1724a2cdd7725a519ebb059a60aca71e24e68 # main
permissions:
contents: read
pull-requests: read # ODP Releaser wants to figure out who made a PR
if: |
github.repository == 'gulfofmaine/Neracoos-1-Buoy-App'
&& github.ref == 'refs/heads/main'
with:
image_name: gmri/neracoos-mariners-dashboard
tag: ${{ needs.push_dev_image.outputs.tag }}
digest: ${{ needs.push_dev_image.outputs.image_digest }}
environment: notify # optional gate
# deploy_targets_path: .github/deploy_targets.yaml # optional
verbosity: 3 # optional, default
secrets:
dispatch_app_id: ${{ secrets.GULFOFMAINE_ODP_DISPATCH_APP_ID }}
dispatch_app_private_key: ${{ secrets.GULFOFMAINE_ODP_DISPATCH_PRIVATE_KEY }}