-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
148 lines (129 loc) · 3.22 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
include:
- template: Security/Dependency-Scanning.gitlab-ci.yml
- template: Security/License-Scanning.gitlab-ci.yml
- template: Security/SAST.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
- template: Security/Container-Scanning.gitlab-ci.yml
image: node:14
stages:
- setup
- docker
- test
- deploy
- release
variables:
CI_APPLICATION_REPOSITORY: $CI_REGISTRY_IMAGE
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == "master"'
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
setup-js:
stage: setup
extends: .node-cache
script:
- yarn install
commitlint:
stage: setup
image: registry.gitlab.com/lepovirta/dis/commitlint-gitlab:latest
script:
- commitlint-gitlab
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
.docker-job:
image: docker:latest
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
build-docker:
stage: docker
extends: .docker-job
variables:
CONTAINER_IMAGE: "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA"
script:
- docker build -t $CONTAINER_IMAGE .
- docker run --rm $CONTAINER_IMAGE
- docker push $CONTAINER_IMAGE
.node-cache:
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- node_modules/
test-js:
stage: test
extends: .node-cache
script:
- yarn run test
artifacts:
reports:
cobertura: coverage/cobertura-coverage.xml
lint-js:
stage: test
extends: .node-cache
script:
- yarn run lint
audit-js:
stage: test
extends: .node-cache
script:
- yarn audit
site-generation:
stage: test
extends: .node-cache
script:
- ./bin/kuvia.js -o kuvia.html -r -d example
pages:
stage: deploy
extends: .node-cache
before_script:
- mkdir -p public
script:
- cp -r example public/
- cd public/example/
- ../../bin/kuvia.js -o index.html -r -d . --no-min
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == "master"
release-npm:
stage: release
before_script:
- npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
script:
- npm publish
rules:
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
release-gitlab:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- release-cli create --name "Release ${CI_COMMIT_TAG}" --tag-name ${CI_COMMIT_TAG}
rules:
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
release-docker-latest:
stage: release
extends: .docker-job
variables:
CONTAINER_IMAGE: "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA"
CONTAINER_IMAGE_RELEASE: "$CI_REGISTRY_IMAGE:latest"
script:
- docker pull $CONTAINER_IMAGE
- docker tag $CONTAINER_IMAGE $CONTAINER_IMAGE_RELEASE
- docker push $CONTAINER_IMAGE_RELEASE
rules:
- if: $CI_COMMIT_BRANCH == "master"
release-docker-tagged:
stage: release
extends: .docker-job
variables:
CONTAINER_IMAGE: "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA"
script:
- "export IMAGE_VERSION=${CI_COMMIT_TAG:1}"
- "export CONTAINER_IMAGE_RELEASE=$CI_REGISTRY_IMAGE:$IMAGE_VERSION"
- docker pull $CONTAINER_IMAGE
- docker tag $CONTAINER_IMAGE $CONTAINER_IMAGE_RELEASE
- docker push $CONTAINER_IMAGE_RELEASE
rules:
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/