-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
86 lines (78 loc) · 1.83 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
stages:
- "prepare"
- "test"
- "publish"
variables:
DOCKER_TLS_CERTDIR: "/certs"
services:
- docker:dind
install:
image: node:latest
stage: prepare
retry: 1
dependencies: []
artifacts:
name: 'deps_$CI_COMMIT_REF_SLUG'
paths:
- node_modules/
when: on_success
expire_in: 12h
script:
- npm install --no-progress --no-audit --no-fund --verbose
eslint:
image: node:latest
stage: test
except:
- tags
retry: 2
allow_failure: true
dependencies:
- install
script:
- npm run test:lint
sast:
stage: test
retry: 2
include:
- template: Security/SAST.gitlab-ci.yml
- template: Security/Dependency-Scanning.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
test:
image: node:latest
stage: test
retry: 2
allow_failure: true
dependencies:
- install
script:
- TEST=1 npx nyc -r text -r cobertura npm test # For creating coverage report
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage/cobertura-coverage.xml
docker-publish:
image: docker:latest
stage: publish
only:
- main
- tags
retry: 2
before_script:
- docker info
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- |
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
tag=""
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
elif [[ -n "$CI_COMMIT_TAG" ]]; then
tag=":$CI_COMMIT_TAG"
echo "Running on tag '$CI_COMMIT_TAG': tag = $tag"
else
tag=":$CI_COMMIT_REF_SLUG"
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
fi
- docker build --pull -t "$CI_REGISTRY/$CI_PROJECT_PATH${tag}" .
- docker push "$CI_REGISTRY/$CI_PROJECT_PATH${tag}"