forked from RocketChat/Rocket.Chat
-
Notifications
You must be signed in to change notification settings - Fork 0
725 lines (594 loc) · 22.9 KB
/
build_and_test.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
724
725
name: Build and Test
on:
release:
types: [published]
pull_request:
branches: '**'
push:
branches:
- develop
env:
CI: true
MONGO_URL: mongodb://localhost:27017
TOOL_NODE_FLAGS: --max_old_space_size=4096
jobs:
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
- name: Use Node.js 14.18.3
uses: actions/setup-node@v2
with:
node-version: '14.18.3'
- uses: actions/checkout@v2
- name: Free disk space
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
docker rmi $(docker image ls -aq)
df -h
- name: check package-lock
run: |
npx package-lock-check
- name: Cache cypress
id: cache-cypress
uses: actions/cache@v2
with:
path: /home/runner/.cache/Cypress
key: ${{ runner.OS }}-cache-cypress-${{ hashFiles('**/package-lock.json', '.github/workflows/build_and_test.yml') }}
# - name: Cache node modules
# id: cache-nodemodules
# uses: actions/cache@v2
# with:
# path: |
# ./node_modules
# ./ee/server/services/node_modules
# key: ${{ runner.OS }}-node_modules-4-${{ hashFiles('**/package-lock.json', '.github/workflows/build_and_test.yml') }}
- name: Cache meteor local
uses: actions/cache@v2
with:
path: ./.meteor/local
key: ${{ runner.OS }}-meteor_cache-${{ hashFiles('.meteor/versions', '.github/workflows/build_and_test.yml') }}
- name: Cache meteor
uses: actions/cache@v2
with:
path: ~/.meteor
key: ${{ runner.OS }}-meteor-${{ hashFiles('.meteor/release', '.github/workflows/build_and_test.yml') }}
- name: Install Meteor
run: |
# Restore bin from cache
set +e
METEOR_SYMLINK_TARGET=$(readlink ~/.meteor/meteor)
METEOR_TOOL_DIRECTORY=$(dirname "$METEOR_SYMLINK_TARGET")
set -e
LAUNCHER=$HOME/.meteor/$METEOR_TOOL_DIRECTORY/scripts/admin/launch-meteor
if [ -e $LAUNCHER ]
then
echo "Cached Meteor bin found, restoring it"
sudo cp "$LAUNCHER" "/usr/local/bin/meteor"
else
echo "No cached Meteor bin found."
fi
# only install meteor if bin isn't found
command -v meteor >/dev/null 2>&1 || curl https://install.meteor.com | sed s/--progress-bar/-sL/g | /bin/sh
- name: Versions
run: |
npm --versions
node -v
meteor --version
meteor npm --versions
meteor node -v
git version
- name: npm install
# if: steps.cache-nodemodules.outputs.cache-hit != 'true' || steps.cache-cypress.outputs.cache-hit != 'true'
run: |
meteor npm install
cd ./ee/server/services
npm install
cd -
- run: meteor npm run lint
- run: meteor npm run translation-check
- name: TS typecheck
run: |
meteor npm run typecheck
cd ./ee/server/services
meteor npm run typecheck
- name: Reset Meteor
if: startsWith(github.ref, 'refs/tags/') == 'true' || github.ref == 'refs/heads/develop'
run: |
meteor reset
- name: Build Rocket.Chat From Pull Request
if: startsWith(github.ref, 'refs/pull/') == true
env:
METEOR_PROFILE: 1000
run: |
meteor build --server-only --directory --debug /tmp/build-test
- name: Build Rocket.Chat
if: startsWith(github.ref, 'refs/pull/') != true
run: |
meteor build --server-only --directory /tmp/build-test
- name: Prepare build
run: |
mkdir /tmp/build/
cd /tmp/build-test
tar czf /tmp/build/Rocket.Chat.tar.gz bundle
cd /tmp/build-test/bundle/programs/server
npm install --production
cd /tmp
tar czf Rocket.Chat.test.tar.gz ./build-test
- name: Store build for tests
uses: actions/upload-artifact@v2
with:
name: build-test
path: /tmp/Rocket.Chat.test.tar.gz
- name: Store build
uses: actions/upload-artifact@v2
with:
name: build
path: /tmp/build
test:
runs-on: ubuntu-20.04
needs: build
strategy:
matrix:
node-version: ['14.18.3']
mongodb-version: ['3.6', '4.0', '4.2', '4.4', '5.0']
steps:
- name: Launch MongoDB
uses: wbari/[email protected]
with:
mongoDBVersion: ${{ matrix.mongodb-version }} --replSet=rs0
- name: Restore build for tests
uses: actions/download-artifact@v2
with:
name: build-test
path: /tmp
- name: Decompress build
run: |
cd /tmp
tar xzf Rocket.Chat.test.tar.gz
cd -
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Setup Chrome
run: |
npm i chromedriver
- name: Configure Replica Set
run: |
docker exec mongo mongo --eval 'rs.initiate({_id:"rs0", members: [{"_id":1, "host":"localhost:27017"}]})'
docker exec mongo mongo --eval 'rs.status()'
- uses: actions/checkout@v2
- name: Cache cypress
id: cache-cypress
uses: actions/cache@v2
with:
path: /home/runner/.cache/Cypress
key: ${{ runner.OS }}-cache-cypress-${{ hashFiles('**/package-lock.json', '.github/workflows/build_and_test.yml') }}
# - name: Cache node modules
# id: cache-nodemodules
# uses: actions/cache@v2
# with:
# path: |
# ./node_modules
# ./ee/server/services/node_modules
# key: ${{ runner.OS }}-node_modules-4-${{ hashFiles('**/package-lock.json', '.github/workflows/build_and_test.yml') }}
- name: NPM install
# if: steps.cache-nodemodules.outputs.cache-hit != 'true' || steps.cache-cypress.outputs.cache-hit != 'true'
run: |
npm install
- name: Unit Test (definitions)
run: npm run testunit-definition
- name: Unit Test
run: npm run testunit
- name: Unit Test (client)
run: npm run testunit-client
- name: E2E Test
env:
TEST_MODE: 'true'
MONGO_URL: mongodb://localhost:27017/rocketchat
MONGO_OPLOG_URL: mongodb://localhost:27017/local
run: |
echo -e 'pcm.!default {\n type hw\n card 0\n}\n\nctl.!default {\n type hw\n card 0\n}' > ~/.asoundrc
Xvfb -screen 0 1024x768x24 :99 &
for i in $(seq 1 5); do (docker exec mongo mongo rocketchat --eval 'db.dropDatabase()') && npm run testci && s=0 && break || s=$? && sleep 1; done; (exit $s)
test-ee:
runs-on: ubuntu-20.04
needs: build
strategy:
matrix:
node-version: ['14.18.3']
mongodb-version: ['4.4']
steps:
- name: Launch MongoDB
uses: wbari/[email protected]
with:
mongoDBVersion: ${{ matrix.mongodb-version }} --replSet=rs0
- name: Launch NATS
run: sudo docker run --name nats -d -p 4222:4222 nats:2.4
- name: Restore build for tests
uses: actions/download-artifact@v2
with:
name: build-test
path: /tmp
- name: Decompress build
run: |
cd /tmp
tar xzf Rocket.Chat.test.tar.gz
cd -
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Setup Chrome
run: |
npm i chromedriver
- name: Configure Replica Set
run: |
docker exec mongo mongo --eval 'rs.initiate({_id:"rs0", members: [{"_id":1, "host":"localhost:27017"}]})'
docker exec mongo mongo --eval 'rs.status()'
- uses: actions/checkout@v2
- name: Cache cypress
id: cache-cypress
uses: actions/cache@v2
with:
path: /home/runner/.cache/Cypress
key: ${{ runner.OS }}-cache-cypress-${{ hashFiles('**/package-lock.json', '.github/workflows/build_and_test.yml') }}
# - name: Cache node modules
# id: cache-nodemodules
# uses: actions/cache@v2
# with:
# path: |
# ./node_modules
# ./ee/server/services/node_modules
# key: ${{ runner.OS }}-node_modules-4-${{ hashFiles('**/package-lock.json', '.github/workflows/build_and_test.yml') }}
- name: NPM install
# if: steps.cache-nodemodules.outputs.cache-hit != 'true' || steps.cache-cypress.outputs.cache-hit != 'true'
run: |
npm install
cd ./ee/server/services
npm install
- name: Build micro services
run: |
cd ./ee/server/services
npm run build
- name: E2E Test
env:
TEST_MODE: 'true'
MONGO_URL: mongodb://localhost:27017/rocketchat
MONGO_OPLOG_URL: mongodb://localhost:27017/local
ENTERPRISE_LICENSE: ${{ secrets.ENTERPRISE_LICENSE }}
TRANSPORTER: nats://localhost:4222
TEST_URL: http://localhost:4000
SKIP_PROCESS_EVENT_REGISTRATION: 'true'
run: |
echo -e 'pcm.!default {\n type hw\n card 0\n}\n\nctl.!default {\n type hw\n card 0\n}' > ~/.asoundrc
Xvfb -screen 0 1024x768x24 :99 &
for i in $(seq 1 5); do (docker exec mongo mongo rocketchat --eval 'db.dropDatabase()') && npm run testci -- --enterprise && s=0 && break || s=$? && sleep 1; done; (exit $s)
# notification:
# runs-on: ubuntu-20.04
# needs: test
# steps:
# - name: Rocket.Chat Notification
# uses: RocketChat/[email protected]
# with:
# type: ${{ job.status }}
# job_name: '**Build and Test**'
# url: ${{ secrets.ROCKETCHAT_WEBHOOK }}
# commit: true
# token: ${{ secrets.GITHUB_TOKEN }}
build-image-pr:
runs-on: ubuntu-20.04
if: github.event.pull_request.head.repo.full_name == github.repository
strategy:
matrix:
release: ['official', 'preview']
steps:
- uses: actions/checkout@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
- name: Free disk space
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
docker rmi $(docker image ls -aq)
df -h
# - name: Cache node modules
# id: cache-nodemodules
# uses: actions/cache@v2
# with:
# path: |
# ./node_modules
# ./ee/server/services/node_modules
# key: ${{ runner.OS }}-node_modules-4-${{ hashFiles('**/package-lock.json', '.github/workflows/build_and_test.yml') }}
- name: Cache meteor local
uses: actions/cache@v2
with:
path: ./.meteor/local
key: ${{ runner.OS }}-meteor_cache-${{ hashFiles('.meteor/versions', '.github/workflows/build_and_test.yml') }}
- name: Cache meteor
uses: actions/cache@v2
with:
path: ~/.meteor
key: ${{ runner.OS }}-meteor-${{ hashFiles('.meteor/release', '.github/workflows/build_and_test.yml') }}
- name: Use Node.js 14.18.3
uses: actions/setup-node@v2
with:
node-version: '14.18.3'
- name: Install Meteor
run: |
# Restore bin from cache
set +e
METEOR_SYMLINK_TARGET=$(readlink ~/.meteor/meteor)
METEOR_TOOL_DIRECTORY=$(dirname "$METEOR_SYMLINK_TARGET")
set -e
LAUNCHER=$HOME/.meteor/$METEOR_TOOL_DIRECTORY/scripts/admin/launch-meteor
if [ -e $LAUNCHER ]
then
echo "Cached Meteor bin found, restoring it"
sudo cp "$LAUNCHER" "/usr/local/bin/meteor"
else
echo "No cached Meteor bin found."
fi
# only install meteor if bin isn't found
command -v meteor >/dev/null 2>&1 || curl https://install.meteor.com | sed s/--progress-bar/-sL/g | /bin/sh
- name: Versions
run: |
npm --versions
node -v
meteor --version
meteor npm --versions
meteor node -v
git version
- name: npm install
# if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: |
meteor npm install
# To reduce memory need during actual build, build the packages solely first
# - name: Build a Meteor cache
# run: |
# # to do this we can clear the main files and it build the rest
# echo "" > server/main.ts
# echo "" > client/main.ts
# sed -i.backup 's/rocketchat:livechat/#rocketchat:livechat/' .meteor/packages
# meteor build --server-only --debug --directory /tmp/build-temp
# git checkout -- server/main.ts client/main.ts .meteor/packages
- name: Build Rocket.Chat
run: |
meteor build --server-only --directory /tmp/build-pr
- name: Build Docker image for PRs
run: |
cd /tmp/build-pr
LOWERCASE_REPOSITORY=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]")
IMAGE_NAME="rocket.chat"
if [[ '${{ matrix.release }}' = 'preview' ]]; then
IMAGE_NAME="${IMAGE_NAME}.preview"
fi;
IMAGE_NAME="ghcr.io/${LOWERCASE_REPOSITORY}/${IMAGE_NAME}:pr-${{ github.event.number }}"
echo "Build official Docker image ${IMAGE_NAME}"
DOCKER_PATH="${GITHUB_WORKSPACE}/.docker"
if [[ '${{ matrix.release }}' = 'preview' ]]; then
DOCKER_PATH="${DOCKER_PATH}-mongo"
fi;
echo "Build ${{ matrix.release }} Docker image"
cp ${DOCKER_PATH}/Dockerfile .
if [ -e ${DOCKER_PATH}/entrypoint.sh ]; then
cp ${DOCKER_PATH}/entrypoint.sh .
fi;
docker build -t $IMAGE_NAME .
docker push $IMAGE_NAME
deploy:
runs-on: ubuntu-20.04
if: github.event_name == 'release' || github.ref == 'refs/heads/develop'
needs: test
steps:
- uses: actions/checkout@v2
- name: Restore build
uses: actions/download-artifact@v2
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 }}
REDHAT_REGISTRY_PID: ${{ secrets.REDHAT_REGISTRY_PID }}
REDHAT_REGISTRY_KEY: ${{ secrets.REDHAT_REGISTRY_KEY }}
UPDATE_TOKEN: ${{ secrets.UPDATE_TOKEN }}
run: |
if [[ '${{ github.event_name }}' = 'release' ]]; then
GIT_TAG="${GITHUB_REF#*tags/}"
GIT_BRANCH=""
ARTIFACT_NAME="$(npm run version --silent)"
RC_VERSION=$GIT_TAG
if [[ $GIT_TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+ ]]; then
SNAP_CHANNEL=candidate
RC_RELEASE=candidate
elif [[ $GIT_TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
SNAP_CHANNEL=stable
RC_RELEASE=stable
fi
else
GIT_TAG=""
GIT_BRANCH="${GITHUB_REF#*heads/}"
ARTIFACT_NAME="$(npm run version --silent).$GITHUB_SHA"
RC_VERSION="$(npm run version --silent)"
SNAP_CHANNEL=edge
RC_RELEASE=develop
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
curl -H "Content-Type: application/json" -H "X-Update-Token: $UPDATE_TOKEN" -d \
"{\"nodeVersion\": \"14.18.3\", \"compatibleMongoVersions\": [\"3.6\", \"4.0\", \"4.2\", \"4.4\", \"5.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
if [[ $GIT_TAG ]]; then
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'"}'
fi
image-build:
runs-on: ubuntu-20.04
needs: deploy
strategy:
matrix:
# this is current a mix of variants and different images
release: ['official', 'preview', 'alpine']
env:
IMAGE_NAME: 'rocketchat/rocket.chat'
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Restore build
uses: actions/download-artifact@v2
with:
name: build
path: /tmp/build
- name: Unpack build and prepare Docker files
run: |
cd /tmp/build
tar xzf Rocket.Chat.tar.gz
rm Rocket.Chat.tar.gz
DOCKER_PATH="${GITHUB_WORKSPACE}/.docker"
if [[ '${{ matrix.release }}' = 'preview' ]]; then
DOCKER_PATH="${DOCKER_PATH}-mongo"
fi;
DOCKERFILE_PATH="${DOCKER_PATH}/Dockerfile"
if [[ '${{ matrix.release }}' = 'alpine' ]]; then
DOCKERFILE_PATH="${DOCKERFILE_PATH}.${{ matrix.release }}"
fi;
echo "Copy Dockerfile for release: ${{ matrix.release }}"
cp $DOCKERFILE_PATH ./Dockerfile
if [ -e ${DOCKER_PATH}/entrypoint.sh ]; then
cp ${DOCKER_PATH}/entrypoint.sh .
fi;
- name: Build Docker image for tag
if: github.event_name == 'release'
run: |
cd /tmp/build
DOCKER_TAG=$GITHUB_REF_NAME
if [[ '${{ matrix.release }}' = 'preview' ]]; then
IMAGE_NAME="${IMAGE_NAME}.preview"
fi;
# append the variant name to docker tag
if [[ '${{ matrix.release }}' = 'alpine' ]]; then
DOCKER_TAG="${DOCKER_TAG}-${{ matrix.release }}"
fi;
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
if [[ '${{ matrix.release }}' = 'alpine' ]]; then
RELEASE="${RELEASE}-${{ matrix.release }}"
fi;
echo "IMAGE_NAME: $IMAGE_NAME"
echo "DOCKER_TAG: $DOCKER_TAG"
echo "RELEASE: $RELEASE"
# build and push the specific tag version
docker build -t $IMAGE_NAME:$DOCKER_TAG .
docker push $IMAGE_NAME:$DOCKER_TAG
if [[ $RELEASE == 'latest' ]]; then
CURRENT_LATEST="$(
git -c 'versionsort.suffix=-' ls-remote -t --exit-code --refs --sort=-v:refname "https://github.com/$GITHUB_REPOSITORY" '*' |
sed -En '1!q;s/^[[:xdigit:]]+[[:space:]]+refs\/tags\/(.+)/\1/gp'
)"
echo "CURRENT_LATEST: $CURRENT_LATEST"
if [[ $CURRENT_LATEST == $GITHUB_REF_NAME ]]; then
docker tag $IMAGE_NAME:$DOCKER_TAG $IMAGE_NAME:$RELEASE
docker push $IMAGE_NAME:$RELEASE
fi
else
docker tag $IMAGE_NAME:$DOCKER_TAG $IMAGE_NAME:$RELEASE
docker push $IMAGE_NAME:$RELEASE
fi
- name: Build Docker image for develop
if: github.ref == 'refs/heads/develop'
run: |
cd /tmp/build
DOCKER_TAG=develop
if [[ '${{ matrix.release }}' = 'preview' ]]; then
IMAGE_NAME="${IMAGE_NAME}.preview"
fi;
if [[ '${{ matrix.release }}' = 'alpine' ]]; then
DOCKER_TAG="${DOCKER_TAG}-${{ matrix.release }}"
fi;
docker build -t $IMAGE_NAME:$DOCKER_TAG .
docker push $IMAGE_NAME:$DOCKER_TAG
services-image-build:
runs-on: ubuntu-20.04
needs: deploy
strategy:
matrix:
service: ['account', 'authorization', 'ddp-streamer', 'presence', 'stream-hub']
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.18.3
uses: actions/setup-node@v2
with:
node-version: '14.18.3'
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Build Docker images
run: |
# defines image tag
if [[ $GITHUB_REF == refs/tags/* ]]; then
IMAGE_TAG="${GITHUB_REF#refs/tags/}"
else
IMAGE_TAG="${GITHUB_REF#refs/heads/}"
fi
# first install repo dependencies
npm i
# then micro services dependencies
cd ./ee/server/services
npm i
npm run build
echo "Building Docker image for service: ${{ matrix.service }}:${IMAGE_TAG}"
docker build --build-arg SERVICE=${{ matrix.service }} -t rocketchat/${{ matrix.service }}-service:${IMAGE_TAG} .
docker push rocketchat/${{ matrix.service }}-service:${IMAGE_TAG}
if [[ $GITHUB_REF == refs/tags/* ]]; then
if echo "$IMAGE_TAG" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' ; then
RELEASE="latest"
elif echo "$IMAGE_TAG" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$' ; then
RELEASE="release-candidate"
fi
docker tag rocketchat/${{ matrix.service }}-service:${IMAGE_TAG} rocketchat/${{ matrix.service }}-service:${RELEASE}
docker push rocketchat/${{ matrix.service }}-service:${RELEASE}
fi