-
Notifications
You must be signed in to change notification settings - Fork 10.9k
723 lines (592 loc) · 25.9 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
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
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
name: CI
on:
release:
types: [published]
pull_request:
branches: '**'
push:
branches:
- develop
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
TOOL_NODE_FLAGS: ${{ vars.TOOL_NODE_FLAGS }}
jobs:
release-versions:
name: ⚙️ Variables Setup
runs-on: ubuntu-latest
outputs:
release: ${{ steps.by-tag.outputs.release }}
latest-release: ${{ steps.latest.outputs.latest-release }}
docker-tag: ${{ steps.docker.outputs.docker-tag }}
gh-docker-tag: ${{ steps.docker.outputs.gh-docker-tag }}
lowercase-repo: ${{ steps.var.outputs.lowercase-repo }}
rc-dockerfile: '${{ github.workspace }}/apps/meteor/.docker/Dockerfile'
rc-docker-tag: '${{ steps.docker.outputs.gh-docker-tag }}.official'
rc-dockerfile-alpine: '${{ github.workspace }}/apps/meteor/.docker/Dockerfile.alpine'
rc-docker-tag-alpine: '${{ steps.docker.outputs.gh-docker-tag }}.alpine'
node-version: ${{ steps.var.outputs.node-version }}
# this is 100% intentional, secrets are not available for forks, so ee-tests will always fail
# to avoid this, we are using a dummy license, expiring at 2024-06-30
enterprise-license: WMa5i+/t/LZbYOj8u3XUkivRhWBtWO6ycUjaZoVAw2DxMfdyBIAa2gMMI4x7Z2BrTZIZhFEImfOxcXcgD0QbXHGBJaMI+eYG+eofnVWi2VA7RWbpvWTULgPFgyJ4UEFeCOzVjcBLTQbmMSam3u0RlekWJkfAO0KnmLtsaEYNNA2rz1U+CLI/CdNGfdqrBu5PZZbGkH0KEzyIZMaykOjzvX+C6vd7fRxh23HecwhkBbqE8eQsCBt2ad0qC4MoVXsDaSOmSzGW+aXjuXt/9zjvrLlsmWQTSlkrEHdNkdywm0UkGxqz3+CP99n0WggUBioUiChjMuNMoceWvDvmxYP9Ml2NpYU7SnfhjmMFyXOah8ofzv8w509Y7XODvQBz+iB4Co9YnF3vT96HDDQyAV5t4jATE+0t37EAXmwjTi3qqyP7DLGK/revl+mlcwJ5kS4zZBsm1E4519FkXQOZSyWRnPdjqvh4mCLqoispZ49wKvklDvjPxCSP9us6cVXLDg7NTJr/4pfxLPOkvv7qCgugDvlDx17bXpQFPSDxmpw66FLzvb5Id0dkWjOzrRYSXb0bFWoUQjtHFzmcpFkyVhOKrQ9zA9+Zm7vXmU9Y2l2dK79EloOuHMSYAqsPEag8GMW6vI/cT4iIjHGGDePKnD0HblvTEKzql11cfT/abf2IiaY=
steps:
- uses: Bhacaz/checkout-files@v2
with:
files: package.json
branch: ${{ github.ref }}
- id: var
run: |
LOWERCASE_REPOSITORY=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]")
echo "LOWERCASE_REPOSITORY: ${LOWERCASE_REPOSITORY}"
echo "lowercase-repo=${LOWERCASE_REPOSITORY}" >> $GITHUB_OUTPUT
NODE_VERSION=$(node -p "require('./package.json').engines.node")
echo "NODE_VERSION: ${NODE_VERSION}"
echo "node-version=${NODE_VERSION}" >> $GITHUB_OUTPUT
- id: by-tag
run: |
if echo "$GITHUB_REF_NAME" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' ; then
RELEASE="latest"
elif echo "$GITHUB_REF_NAME" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$' ; then
RELEASE="release-candidate"
fi
echo "RELEASE: ${RELEASE}"
echo "release=${RELEASE}" >> $GITHUB_OUTPUT
- id: latest
run: |
LATEST_RELEASE="$(
git -c 'versionsort.suffix=-' ls-remote -t --exit-code --refs --sort=-v:refname "https://github.com/$GITHUB_REPOSITORY" '*' |
awk -F/ '$NF !~ /rc|beta/ { print $NF; exit }'
)"
echo "LATEST_RELEASE: ${LATEST_RELEASE}"
echo "latest-release=${LATEST_RELEASE}" >> $GITHUB_OUTPUT
- id: docker
run: |
if [[ '${{ github.event_name }}' == 'pull_request' ]]; then
DOCKER_TAG="pr-${{ github.event.number }}"
else
DOCKER_TAG="gh-${{ github.run_id }}"
fi
echo "DOCKER_TAG: ${DOCKER_TAG}"
echo "gh-docker-tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT
packages-build:
name: 📦 Build Packages
needs: [release-versions]
runs-on: ubuntu-20.04
steps:
- name: Github Info
run: |
echo "GITHUB_ACTION: $GITHUB_ACTION"
echo "GITHUB_ACTOR: $GITHUB_ACTOR"
echo "GITHUB_REF: $GITHUB_REF"
echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF"
echo "GITHUB_BASE_REF: $GITHUB_BASE_REF"
echo "github.event_name: ${{ github.event_name }}"
cat $GITHUB_EVENT_PATH
- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 4
- uses: actions/checkout@v3
- name: Setup NodeJS
uses: ./.github/actions/setup-node
with:
node-version: ${{ needs.release-versions.outputs.node-version }}
cache-modules: true
install: true
- name: Cache vite
uses: actions/cache@v3
with:
path: ./node_modules/.vite
key: vite-local-cache-${{ runner.OS }}-${{ hashFiles('package.json') }}
restore-keys: |
vite-local-cache-${{ runner.os }}-
- uses: dtinth/setup-github-actions-caching-for-turbo@v1
- name: Build Rocket.Chat Packages
run: yarn build
build:
name: 📦 Meteor Build - coverage
needs: [release-versions, packages-build]
runs-on: ubuntu-20.04
steps:
- name: Github Info
run: |
echo "GITHUB_ACTION: $GITHUB_ACTION"
echo "GITHUB_ACTOR: $GITHUB_ACTOR"
echo "GITHUB_REF: $GITHUB_REF"
echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF"
echo "GITHUB_BASE_REF: $GITHUB_BASE_REF"
echo "github.event_name: ${{ github.event_name }}"
cat $GITHUB_EVENT_PATH
- uses: actions/checkout@v3
- uses: ./.github/actions/meteor-build
with:
node-version: ${{ needs.release-versions.outputs.node-version }}
coverage: true
build-prod:
name: 📦 Meteor Build - official
needs: [tests-done, release-versions, packages-build]
if: (github.event_name == 'release' || github.ref == 'refs/heads/develop')
runs-on: ubuntu-20.04
steps:
- name: Github Info
run: |
echo "GITHUB_ACTION: $GITHUB_ACTION"
echo "GITHUB_ACTOR: $GITHUB_ACTOR"
echo "GITHUB_REF: $GITHUB_REF"
echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF"
echo "GITHUB_BASE_REF: $GITHUB_BASE_REF"
echo "github.event_name: ${{ github.event_name }}"
cat $GITHUB_EVENT_PATH
- uses: actions/checkout@v3
- uses: ./.github/actions/meteor-build
with:
node-version: ${{ needs.release-versions.outputs.node-version }}
coverage: false
build-gh-docker-coverage:
name: 🚢 Build Docker Images for Testing
needs: [build, release-versions]
runs-on: ubuntu-20.04
env:
RC_DOCKERFILE: ${{ matrix.platform == 'alpine' && needs.release-versions.outputs.rc-dockerfile-alpine || needs.release-versions.outputs.rc-dockerfile }}
RC_DOCKER_TAG: ${{ matrix.platform == 'alpine' && needs.release-versions.outputs.rc-docker-tag-alpine || needs.release-versions.outputs.rc-docker-tag }}
DOCKER_TAG: ${{ needs.release-versions.outputs.gh-docker-tag }}
LOWERCASE_REPOSITORY: ${{ needs.release-versions.outputs.lowercase-repo }}
SERVICES_PUBLISH: 'authorization-service account-service ddp-streamer-service presence-service stream-hub-service'
strategy:
fail-fast: false
matrix:
platform: ['official', 'alpine']
steps:
- uses: actions/checkout@v3
# we only build and publish the actual docker images if not a PR from a fork
- uses: ./.github/actions/build-docker
if: (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop')
with:
CR_USER: ${{ secrets.CR_USER }}
CR_PAT: ${{ secrets.CR_PAT }}
node-version: ${{ needs.release-versions.outputs.node-version }}
platform: ${{ matrix.platform }}
build-gh-docker:
name: 🚢 Build Docker Images for Production
needs: [build-prod, release-versions]
runs-on: ubuntu-20.04
env:
RC_DOCKERFILE: ${{ matrix.platform == 'alpine' && needs.release-versions.outputs.rc-dockerfile-alpine || needs.release-versions.outputs.rc-dockerfile }}
RC_DOCKER_TAG: ${{ matrix.platform == 'alpine' && needs.release-versions.outputs.rc-docker-tag-alpine || needs.release-versions.outputs.rc-docker-tag }}
DOCKER_TAG: ${{ needs.release-versions.outputs.gh-docker-tag }}
LOWERCASE_REPOSITORY: ${{ needs.release-versions.outputs.lowercase-repo }}
SERVICES_PUBLISH: 'authorization-service account-service ddp-streamer-service presence-service stream-hub-service'
strategy:
fail-fast: false
matrix:
platform: ['official', 'alpine']
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/build-docker
with:
CR_USER: ${{ secrets.CR_USER }}
CR_PAT: ${{ secrets.CR_PAT }}
node-version: ${{ needs.release-versions.outputs.node-version }}
platform: ${{ matrix.platform }}
- name: Rename official Docker tag to GitHub Container Registry
if: matrix.platform == 'official'
run: |
IMAGE_NAME_BASE="ghcr.io/${LOWERCASE_REPOSITORY}/rocket.chat:${DOCKER_TAG}"
echo "Push Docker image: ${IMAGE_NAME_BASE}"
docker tag ${IMAGE_NAME_BASE}.official $IMAGE_NAME_BASE
docker push $IMAGE_NAME_BASE
checks:
needs: [release-versions, packages-build]
name: 🔎 Code Check
uses: ./.github/workflows/ci-code-check.yml
with:
node-version: ${{ needs.release-versions.outputs.node-version }}
test-unit:
name: 🔨 Test Unit
needs: [packages-build, release-versions]
uses: ./.github/workflows/ci-test-unit.yml
with:
node-version: ${{ needs.release-versions.outputs.node-version }}
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
test-api:
name: 🔨 Test API (CE)
needs: [checks, build-gh-docker-coverage, release-versions]
uses: ./.github/workflows/ci-test-e2e.yml
with:
type: api
release: ce
node-version: ${{ needs.release-versions.outputs.node-version }}
lowercase-repo: ${{ needs.release-versions.outputs.lowercase-repo }}
rc-dockerfile: ${{ needs.release-versions.outputs.rc-dockerfile }}
rc-docker-tag: ${{ needs.release-versions.outputs.rc-docker-tag }}
rc-dockerfile-alpine: ${{ needs.release-versions.outputs.rc-dockerfile-alpine }}
rc-docker-tag-alpine: ${{ needs.release-versions.outputs.rc-docker-tag-alpine }}
gh-docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
secrets:
CR_USER: ${{ secrets.CR_USER }}
CR_PAT: ${{ secrets.CR_PAT }}
test-ui:
name: 🔨 Test UI (CE)
needs: [checks, build-gh-docker-coverage, release-versions]
uses: ./.github/workflows/ci-test-e2e.yml
with:
type: ui
release: ce
transporter: 'nats://nats:4222'
enterprise-license: ${{ needs.release-versions.outputs.enterprise-license }}
shard: '[1, 2, 3, 4]'
total-shard: 4
node-version: ${{ needs.release-versions.outputs.node-version }}
lowercase-repo: ${{ needs.release-versions.outputs.lowercase-repo }}
rc-dockerfile: ${{ needs.release-versions.outputs.rc-dockerfile }}
rc-docker-tag: ${{ needs.release-versions.outputs.rc-docker-tag }}
rc-dockerfile-alpine: ${{ needs.release-versions.outputs.rc-dockerfile-alpine }}
rc-docker-tag-alpine: ${{ needs.release-versions.outputs.rc-docker-tag-alpine }}
gh-docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
secrets:
CR_USER: ${{ secrets.CR_USER }}
CR_PAT: ${{ secrets.CR_PAT }}
QASE_API_TOKEN: ${{ secrets.QASE_API_TOKEN }}
REPORTER_ROCKETCHAT_API_KEY: ${{ secrets.REPORTER_ROCKETCHAT_API_KEY }}
REPORTER_ROCKETCHAT_URL: ${{ secrets.REPORTER_ROCKETCHAT_URL }}
test-api-ee:
name: 🔨 Test API (EE)
needs: [checks, build-gh-docker-coverage, release-versions]
uses: ./.github/workflows/ci-test-e2e.yml
with:
type: api
release: ee
transporter: 'nats://nats:4222'
enterprise-license: ${{ needs.release-versions.outputs.enterprise-license }}
mongodb-version: "['4.4']"
node-version: ${{ needs.release-versions.outputs.node-version }}
lowercase-repo: ${{ needs.release-versions.outputs.lowercase-repo }}
rc-dockerfile: ${{ needs.release-versions.outputs.rc-dockerfile }}
rc-docker-tag: ${{ needs.release-versions.outputs.rc-docker-tag }}
rc-dockerfile-alpine: ${{ needs.release-versions.outputs.rc-dockerfile-alpine }}
rc-docker-tag-alpine: ${{ needs.release-versions.outputs.rc-docker-tag-alpine }}
gh-docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
secrets:
CR_USER: ${{ secrets.CR_USER }}
CR_PAT: ${{ secrets.CR_PAT }}
test-ui-ee:
name: 🔨 Test UI (EE)
needs: [checks, build-gh-docker-coverage, release-versions]
uses: ./.github/workflows/ci-test-e2e.yml
with:
type: ui
release: ee
transporter: 'nats://nats:4222'
enterprise-license: ${{ needs.release-versions.outputs.enterprise-license }}
shard: '[1, 2, 3, 4, 5]'
total-shard: 5
mongodb-version: "['4.4']"
node-version: ${{ needs.release-versions.outputs.node-version }}
lowercase-repo: ${{ needs.release-versions.outputs.lowercase-repo }}
rc-dockerfile: ${{ needs.release-versions.outputs.rc-dockerfile }}
rc-docker-tag: ${{ needs.release-versions.outputs.rc-docker-tag }}
rc-dockerfile-alpine: ${{ needs.release-versions.outputs.rc-dockerfile-alpine }}
rc-docker-tag-alpine: ${{ needs.release-versions.outputs.rc-docker-tag-alpine }}
gh-docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
secrets:
CR_USER: ${{ secrets.CR_USER }}
CR_PAT: ${{ secrets.CR_PAT }}
QASE_API_TOKEN: ${{ secrets.QASE_API_TOKEN }}
REPORTER_ROCKETCHAT_API_KEY: ${{ secrets.REPORTER_ROCKETCHAT_API_KEY }}
REPORTER_ROCKETCHAT_URL: ${{ secrets.REPORTER_ROCKETCHAT_URL }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
tests-done:
name: ✅ Tests Done
runs-on: ubuntu-20.04
needs: [checks, test-unit, test-api, test-ui, test-api-ee, test-ui-ee]
steps:
- name: Test finish aggregation
run: |
echo finished
deploy:
name: 🚀 Publish build assets
runs-on: ubuntu-20.04
if: github.event_name == 'release' || github.ref == 'refs/heads/develop'
needs: [build-gh-docker, release-versions]
steps:
- uses: Bhacaz/checkout-files@v2
with:
files: package.json
branch: ${{ github.ref }}
- name: Restore build
uses: actions/download-artifact@v3
with:
name: build
path: /tmp/build
- name: Publish assets
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'us-east-1'
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
run: |
REPO_VERSION=$(node -p "require('./package.json').version")
if [[ '${{ github.event_name }}' = 'release' ]]; then
GIT_TAG="${GITHUB_REF#*tags/}"
ARTIFACT_NAME="${REPO_VERSION}"
else
GIT_TAG=""
ARTIFACT_NAME="${REPO_VERSION}.$GITHUB_SHA"
fi;
ROCKET_DEPLOY_DIR="/tmp/deploy"
FILENAME="$ROCKET_DEPLOY_DIR/rocket.chat-$ARTIFACT_NAME.tgz";
aws s3 cp s3://rocketchat/sign.key.gpg .github/sign.key.gpg
mkdir -p $ROCKET_DEPLOY_DIR
cp .github/sign.key.gpg /tmp
gpg --yes --batch --passphrase=$GPG_PASSWORD /tmp/sign.key.gpg
gpg --allow-secret-key-import --import /tmp/sign.key
rm /tmp/sign.key
ln -s /tmp/build/Rocket.Chat.tar.gz "$FILENAME"
gpg --armor --detach-sign "$FILENAME"
aws s3 cp $ROCKET_DEPLOY_DIR/ s3://download.rocket.chat/build/ --recursive
build-docker-preview:
name: 🚢 Build Docker Image (preview)
runs-on: ubuntu-20.04
needs: [build, checks, release-versions]
if: github.event_name == 'release' || github.ref == 'refs/heads/develop'
steps:
- uses: actions/checkout@v3
- name: Restore build
uses: actions/download-artifact@v3
with:
name: build
path: /tmp/build
- name: Unpack build
run: |
cd /tmp/build
tar xzf Rocket.Chat.tar.gz
rm Rocket.Chat.tar.gz
- name: Build Docker image
id: build-docker-image-preview
uses: ./.github/actions/build-docker-image
with:
root-dir: /tmp/build
docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
release: preview
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
docker-image-publish:
name: 🚀 Publish Docker Image (main)
runs-on: ubuntu-20.04
needs: [deploy, build-docker-preview, release-versions]
strategy:
matrix:
# this is currently a mix of variants and different images
release: ['official', 'preview', 'alpine']
env:
IMAGE_NAME: 'rocketchat/rocket.chat'
steps:
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
- name: Get Docker image name
id: gh-docker
run: |
GH_IMAGE_NAME="ghcr.io/${{ needs.release-versions.outputs.lowercase-repo }}/rocket.chat:${{ needs.release-versions.outputs.gh-docker-tag }}.${{ matrix.release }}"
echo "GH_IMAGE_NAME: $GH_IMAGE_NAME"
echo "gh-image-name=${GH_IMAGE_NAME}" >> $GITHUB_OUTPUT
DOCKER_TAG_SHA="sha-${GITHUB_SHA:0:7}"
echo "DOCKER_TAG_SHA: ${DOCKER_TAG_SHA}"
echo "gh-docker-tag-sha=${DOCKER_TAG_SHA}" >> $GITHUB_OUTPUT
- name: Pull Docker image
run: docker pull ${{ steps.gh-docker.outputs.gh-image-name }}
- name: Publish Docker image
run: |
if [[ '${{ matrix.release }}' = 'preview' ]]; then
IMAGE_NAME="${IMAGE_NAME}.preview"
fi;
# 'develop' or 'tag'
DOCKER_TAG=$GITHUB_REF_NAME
# append the variant name to docker tag
if [[ '${{ matrix.release }}' = 'alpine' ]]; then
DOCKER_TAG="${DOCKER_TAG}-${{ matrix.release }}"
fi;
PUBLISHED_TAGS=()
# tag and push the specific tag version
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $IMAGE_NAME:$DOCKER_TAG
docker push $IMAGE_NAME:$DOCKER_TAG
PUBLISHED_TAGS+=("$IMAGE_NAME:$DOCKER_TAG")
if [[ $GITHUB_REF == refs/tags/* ]]; then
RELEASE="${{ needs.release-versions.outputs.release }}"
if [[ '${{ matrix.release }}' = 'alpine' ]]; then
RELEASE="${RELEASE}-${{ matrix.release }}"
fi;
echo "RELEASE: $RELEASE"
if [[ $RELEASE == 'latest' ]]; then
if [[ '${{ needs.release-versions.outputs.latest-release }}' == $GITHUB_REF_NAME ]]; then
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $IMAGE_NAME:$RELEASE
docker push $IMAGE_NAME:$RELEASE
PUBLISHED_TAGS+=("$IMAGE_NAME:$RELEASE")
fi
else
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $IMAGE_NAME:$RELEASE
docker push $IMAGE_NAME:$RELEASE
PUBLISHED_TAGS+=("$IMAGE_NAME:$RELEASE")
fi
fi
# commit hash
TAG_SHA="${{ steps.gh-docker.outputs.gh-docker-tag-sha }}"
# append the variant name to docker tag
if [[ '${{ matrix.release }}' = 'alpine' ]]; then
TAG_SHA="${TAG_SHA}-${{ matrix.release }}"
fi;
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $IMAGE_NAME:$TAG_SHA
docker push $IMAGE_NAME:$TAG_SHA
PUBLISHED_TAGS+=("$IMAGE_NAME:$TAG_SHA")
echo "::group::Published tags"
for TAG in ${PUBLISHED_TAGS[@]}; do
echo $TAG
done
echo "::endgroup::"
services-docker-image-publish:
name: 🚀 Publish Docker Image (services)
runs-on: ubuntu-20.04
needs: [deploy, release-versions]
strategy:
matrix:
service: ['account', 'authorization', 'ddp-streamer', 'presence', 'stream-hub']
steps:
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
- name: Get Docker image name
id: gh-docker
run: |
GH_IMAGE_NAME="ghcr.io/${{ needs.release-versions.outputs.lowercase-repo }}/${{ matrix.service }}-service:${{ needs.release-versions.outputs.gh-docker-tag }}"
echo "GH_IMAGE_NAME: $GH_IMAGE_NAME"
echo "gh-image-name=${GH_IMAGE_NAME}" >> $GITHUB_OUTPUT
DOCKER_TAG_SHA="sha-${GITHUB_SHA:0:7}"
echo "DOCKER_TAG_SHA: ${DOCKER_TAG_SHA}"
echo "gh-docker-tag-sha=${DOCKER_TAG_SHA}" >> $GITHUB_OUTPUT
- name: Pull Docker image
run: docker pull ${{ steps.gh-docker.outputs.gh-image-name }}
- name: Publish Docker images
run: |
DH_IMAGE_NAME="rocketchat/${{ matrix.service }}-service"
# 'develop' or 'tag'
DOCKER_TAG=$GITHUB_REF_NAME
PUBLISHED_TAGS=()
# tag and push the specific tag version
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $DH_IMAGE_NAME:$DOCKER_TAG
docker push $DH_IMAGE_NAME:$DOCKER_TAG
PUBLISHED_TAGS+=("$DH_IMAGE_NAME:$DOCKER_TAG")
if [[ $GITHUB_REF == refs/tags/* ]]; then
RELEASE="${{ needs.release-versions.outputs.release }}"
if [[ $RELEASE == 'latest' ]]; then
if [[ '${{ needs.release-versions.outputs.latest-release }}' == $GITHUB_REF_NAME ]]; then
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $DH_IMAGE_NAME:$RELEASE
docker push $DH_IMAGE_NAME:$RELEASE
PUBLISHED_TAGS+=("$DH_IMAGE_NAME:$RELEASE")
fi
else
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $DH_IMAGE_NAME:$RELEASE
docker push $DH_IMAGE_NAME:$RELEASE
PUBLISHED_TAGS+=("$DH_IMAGE_NAME:$RELEASE")
fi
fi
# commit hash
TAG_SHA="${{ steps.gh-docker.outputs.gh-docker-tag-sha }}"
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $DH_IMAGE_NAME:$TAG_SHA
docker push $DH_IMAGE_NAME:$TAG_SHA
PUBLISHED_TAGS+=("$DH_IMAGE_NAME:$TAG_SHA")
echo "::group::Published tags"
for TAG in ${PUBLISHED_TAGS[@]}; do
echo $TAG
done
echo "::endgroup::"
notify-services:
name: 🚀 Notify external services
runs-on: ubuntu-20.04
needs:
- services-docker-image-publish
- docker-image-publish
- release-versions
steps:
- uses: Bhacaz/checkout-files@v2
with:
files: package.json
branch: ${{ github.ref }}
- name: Releases service
env:
UPDATE_TOKEN: ${{ secrets.UPDATE_TOKEN }}
run: |
REPO_VERSION=$(node -p "require('./package.json').version")
if [[ '${{ github.event_name }}' = 'release' ]]; then
GIT_TAG="${GITHUB_REF#*tags/}"
GIT_BRANCH=""
ARTIFACT_NAME="${REPO_VERSION}"
RC_VERSION=$GIT_TAG
if [[ '${{ needs.release-versions.outputs.release }}' = 'release-candidate' ]]; then
RC_RELEASE=candidate
elif [[ '${{ needs.release-versions.outputs.release }}' = 'latest' ]]; then
RC_RELEASE=stable
fi
else
GIT_TAG=""
GIT_BRANCH="${GITHUB_REF#*heads/}"
ARTIFACT_NAME="${REPO_VERSION}.$GITHUB_SHA"
RC_VERSION="${REPO_VERSION}"
RC_RELEASE=develop
fi;
curl -H "Content-Type: application/json" -H "X-Update-Token: $UPDATE_TOKEN" -d \
"{\"nodeVersion\": \"${{ needs.release-versions.outputs.node-version }}\", \"compatibleMongoVersions\": [\"4.4\", \"5.0\", \"6.0\"], \"commit\": \"$GITHUB_SHA\", \"tag\": \"$RC_VERSION\", \"branch\": \"$GIT_BRANCH\", \"artifactName\": \"$ARTIFACT_NAME\", \"releaseType\": \"$RC_RELEASE\"}" \
https://releases.rocket.chat/update
# Makes build fail if the release isn't there
curl --fail https://releases.rocket.chat/$RC_VERSION/info
- name: RedHat Registry
if: github.event_name == 'release'
env:
REDHAT_REGISTRY_PID: ${{ secrets.REDHAT_REGISTRY_PID }}
REDHAT_REGISTRY_KEY: ${{ secrets.REDHAT_REGISTRY_KEY }}
run: |
GIT_TAG="${GITHUB_REF#*tags/}"
curl -X POST \
https://connect.redhat.com/api/v2/projects/$REDHAT_REGISTRY_PID/build \
-H "Authorization: Bearer $REDHAT_REGISTRY_KEY" \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{"tag":"'$GIT_TAG'"}'
trigger-dependent-workflows:
runs-on: ubuntu-latest
if: github.event_name == 'release'
needs:
- services-docker-image-publish
- docker-image-publish
steps:
- name: Send context to seperate pipeline
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.DISTRIBUTION_TOKEN }}
event-type: new_release
repository: RocketChat/Release.Distributions
client-payload: '{"tag": "${{ github.ref_name }}"}'
- name: Update docs
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.DOCS_PAT }}
event-type: new_release
repository: RocketChat/docs
client-payload: '{"tag": "${{ github.ref_name }}"}'