forked from Synerise/synerise-design
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
156 lines (139 loc) · 4.54 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
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
image: node:lts
variables:
APP: ds-docs
NODE_OPTIONS: --max-old-space-size=4096
DOCKER_TLS_CERTDIR: ""
FF_NETWORK_PER_BUILD: "true"
cache:
key: ds
paths:
- node_modules/
services:
- docker:dind
stages:
- test
- build
- deploy
include:
- template: Code-Quality.gitlab-ci.yml
- project: 'Core/gitlab_templates'
ref: master
file: '/core_deploy_kapitan.yml'
build:
stage: test
except:
refs:
- tags
tags:
- vms
script:
- yarn --frozen-lockfile
- yarn lint
- yarn build
- yarn test:ci
- echo "Tag version $CI_COMMIT_TAG"
- echo "Commit ref $CI_COMMIT_REF_NAME"
- echo "Publisher $GITLAB_USER_EMAIL"
- echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}'>.npmrc
- echo "email = $GITLAB_USER_EMAIL" >> .npmrc
- (if [ "$CI_COMMIT_REF_NAME" == "master" ]; then npx lerna publish from-package --no-git-tag-version --yes;fi);
docs_build:
image: node:lts
stage: test
only:
refs:
- tags
- master
- dev
script:
- yarn --frozen-lockfile
- yarn build
- yarn npx:lerna run postinstall
- yarn npx:lerna run build-docs
- mv packages/portal/storybook-static/ packages/docs-site/website/build
- yarn docs-build
- mv docs/dist/ packages/docs-site/website/build/styleguide
artifacts:
paths:
- packages/docs-site/website/build/*
docs_deploy:
image: docker:stable
stage: build
needs: ['docs_build']
only:
refs:
- master
- dev
allow_failure: true
script:
- SANITY_BRANCH=$CI_COMMIT_REF_SLUG
- echo "Sanitized branch name ${SANITY_BRANCH}"
- docker login $QUAY_REPO_HOST -u "$QUAY_REPO_USER" -p "$QUAY_REPO_PASS"
- cd packages/docs-site
- pwd
- docker build -t ds-docs .
- echo "Push commit image"
- docker tag ds-docs quay.io/synerise/ds-docs:"$SANITY_BRANCH"-"${CI_COMMIT_SHA}"
- docker push quay.io/synerise/ds-docs:"$SANITY_BRANCH"-"${CI_COMMIT_SHA}"
- echo "Image pushed to remote repository from branch ${CI_COMMIT_REF_NAME}"
- docker tag ds-docs quay.io/synerise/ds-docs:"$SANITY_BRANCH"-latest
- docker push quay.io/synerise/ds-docs:"$SANITY_BRANCH"-latest
- echo "Image pushed to remote repository from branch ${CI_COMMIT_REF_NAME} for commit ${CI_COMMIT_SHA}"
docs_deploy_from_tag:
image: docker:stable
stage: build
needs: ['docs_build']
only:
refs:
- tags
allow_failure: true
script:
- SANITY_BRANCH=$CI_COMMIT_REF_SLUG
- echo "Sanitized branch name ${SANITY_BRANCH}"
- docker login $QUAY_REPO_HOST -u "$QUAY_REPO_USER" -p "$QUAY_REPO_PASS"
- cd packages/docs-site
- pwd
- docker build -t ds-docs .
- echo "Push commit image"
- docker tag ds-docs quay.io/synerise/ds-docs:"$SANITY_BRANCH"-"${CI_COMMIT_SHA}"
- docker push quay.io/synerise/ds-docs:"$SANITY_BRANCH"-"${CI_COMMIT_SHA}"
- echo "Image pushed to remote repository from branch ${CI_COMMIT_REF_NAME}"
- docker tag ds-docs quay.io/synerise/ds-docs:"$SANITY_BRANCH"
- docker push quay.io/synerise/ds-docs:"$SANITY_BRANCH"
- echo "Image pushed to remote repository from branch ${CI_COMMIT_REF_NAME} for commit ${CI_COMMIT_SHA}"
k8s-deploy-branch-release:
extends: .k8s-deploy-branch-stage
stage: deploy
variables:
APPLICATION: ${APP}
NAMESPACE: jsons
CURRENT_TAG: $CI_COMMIT_REF_SLUG-$CI_COMMIT_SHA
only:
- dev
chromatic_publish:
stage: deploy
only:
refs:
- merge_requests
variables:
- $CHROMATIC_PROJECT_TOKEN
script:
- test ! -e packages/portal/storybook-static && (yarn install && yarn npx:lerna run build ${SB_OPTS:---since}; cd packages/portal; yarn build-docs --quiet)
- (cd packages/portal; npx chromatic ${SB_DEPLOY_OPTS:---allow-console-errors --exit-zero-on-changes} --project-token=$CHROMATIC_PROJECT_TOKEN --storybook-build-dir ./storybook-static/)
chromatic_publish_merge_to_dest_branch:
stage: deploy
when: manual
only:
refs:
- merge_requests
variables:
- $CHROMATIC_PROJECT_TOKEN
- $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
- $EMAIL
- $GIT_AUTHOR_NAME
- $GIT_COMMITTER_NAME
allow_failure: true
script:
- git checkout HEAD~0; git merge --no-commit origin/"$CI_MERGE_REQUEST_TARGET_BRANCH_NAME";
- test ! -e packages/portal/storybook-static && (yarn install && yarn npx:lerna run build ${SB_OPTS:---since}; cd packages/portal; yarn build-docs --quiet)
- (cd packages/portal; npx chromatic ${SB_DEPLOY_OPTS:---allow-console-errors --exit-zero-on-changes} --project-token=$CHROMATIC_PROJECT_TOKEN --storybook-build-dir ./storybook-static/)