-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.gitlab-ci.yml
112 lines (104 loc) · 2.84 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
image: docker:20
variables:
GIT_DEPTH: 0
GIT_SUBMODULE_STRATEGY: recursive
CONTAINER_BASE: "${CI_REGISTRY}/${CI_PROJECT_PATH}"
DOCKER_HUB_BASE_TAG: "yeswehack/my-open-vdp"
stages:
- check
- build
- build-docker
- publish
Lint:
stage: check
tags:
- docker20
image: node:18-alpine
cache:
paths:
- ui/node_modules
script:
- cd ui && yarn install && yarn lint
Check Versions:
stage: check
tags:
- docker20
artifacts:
paths:
- version.txt
script:
- apk update && apk add jq
- jq -r '.version' ui/package.json > version.txt
- diff -u version.txt <(jq -r '.version' app-extension/package.json) || exit 1
Build UI:
stage: build
tags:
- docker20
image: node:18-alpine
cache:
paths:
- ui/node_modules
script:
- cd ui && yarn install && yarn build
artifacts:
paths:
- ui/dist
expire_in: 1 day
Build Docker:
stage: build-docker
tags:
- docker20
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [ "" ]
script:
# there's an issue with kaniko with multi-stage builds and symlinks
# so we get ui dist files from ui build artifact
- rm -rf app/public/my-open-vdp
- cp -rv ui/dist app/public/my-open-vdp
- export VERSION=$(cat version.txt)
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"${DOCKER_AUTH}\"}}}" > /kaniko/.docker/config.json
- >-
/kaniko/executor --cache=true --context .
--dockerfile docker/Dockerfile
--destination "${CONTAINER_BASE}:${CI_COMMIT_REF_SLUG}-${VERSION}"
Publish npm:
stage: publish
tags:
- docker20
image: node:18-alpine
when: manual
only:
- tags
script:
- wget -qO- https://registry.npmjs.org/quasar-ui-my-open-vdp
- cd ui
- echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > .npmrc
- echo "//registry.npmjs.org/:username=zerodisclo" >> .npmrc
- npm publish
- cd ../app-extension
- echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > .npmrc
- echo "//registry.npmjs.org/:username=zerodisclo" >> .npmrc
- npm publish
Publish Docker Hub:
stage: publish
tags:
- docker20
services:
- name: "docker:20-dind"
alias: docker
when: manual
only:
- tags
script:
- export VERSION=$(cat version.txt)
- export DOCKER_LOCAL_TAG="${CONTAINER_BASE}:${CI_COMMIT_REF_SLUG}-${VERSION}"
- export DOCKER_HUB_TAG="${DOCKER_HUB_BASE_TAG}:${VERSION}"
- export DOCKER_HUB_TAG_LATEST="${DOCKER_HUB_BASE_TAG}:latest"
- docker pull "${DOCKER_LOCAL_TAG}"
- echo "${DOCKER_HUB_PASSWORD}" | docker login -u "${DOCKER_HUB_LOGIN}" --password-stdin
- docker tag "${DOCKER_LOCAL_TAG}" "${DOCKER_HUB_TAG}"
- docker push "${DOCKER_HUB_TAG}"
- docker tag "${DOCKER_LOCAL_TAG}" "${DOCKER_HUB_TAG_LATEST}"
- docker push "${DOCKER_HUB_TAG_LATEST}"