-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
94 lines (84 loc) · 2.47 KB
/
.gitlab-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
image:
name: $DOCKER_REGISTRY/cicd/node-ci-image:1.0-node20
entrypoint: [ '/bin/bash', '-s' ]
variables:
CI: ''
IMAGE_NAME: $DOCKER_REGISTRY/astrea/astrea-react-storybook
IMAGE_VERSION: $BRANCH_NAME
stages:
- build
- publishSite
- test
- analysis
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
before_script:
- 'echo CI coordinates: $CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE'
- 'echo nexus auth: $CI_NEXUS_USERNAME'
# Run the build to check that we don't have any errors
buildPackage:
stage: build
script:
- corepack enable && corepack prepare pnpm@latest --activate
- pnpm install
- pnpm run build
- pnpm pack
artifacts:
paths:
- 'netservice-astrea-react-ds-*.tgz'
expire_in: 1 week
only:
- master
- tags
# Run the build to check that we don't have any errors
buildPackageAndStorybook:
stage: build
script:
- corepack enable && corepack prepare pnpm@latest --activate
- pnpm install
- pnpm run build
- pnpm run build-storybook
except:
- master
- tags
deploySite:
stage: publishSite
image: $DOCKER_REGISTRY/docker/docker:default
script:
- 'export PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: ''{ print $2 }'' | sed ''s/[", ]//g'')'
- sed -i "s/latest/$PACKAGE_VERSION/" docker-compose.yml
- docker images
- docker image prune -f || true
- docker volume prune -f || true
- docker -H "tcp://$REMOTE_DOCKER_HOST:2375" --tlsverify=1 --tlscacert=$CA_PEM --tlscert=$CERT_PEM --tlskey=$KEY_PEM compose down
- docker -H "tcp://$REMOTE_DOCKER_HOST:2375" --tlsverify=1 --tlscacert=$CA_PEM --tlscert=$CERT_PEM --tlskey=$KEY_PEM compose up -d --build --remove-orphans
tags:
- docker
only:
- master
runTests:
stage: test
script:
- corepack enable && corepack prepare pnpm@latest --activate
- pnpm install
- pnpm test
artifacts:
paths:
- coverage/
expire_in: 1 day
sonarManual:
stage: analysis
when: manual
script:
- sonar-scanner -Dsonar.host.url=$CI_SONAR_URL -Dsonar.login=$CI_SONAR_TOKEN -Dsonar.verbose=true -Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
except:
- tags
sonar:
stage: analysis
script:
- sonar-scanner -Dsonar.host.url=$CI_SONAR_URL -Dsonar.login=$CI_SONAR_TOKEN -Dsonar.verbose=true -Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
only:
variables:
- $CI_COMMIT_TAG =~ /(([0-9]*)(\.))(([0-9]{2})(\.)){2}([0-9]){3}((-RC)([0-9]+))?/