forked from olkitu/Mobilespectrum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
132 lines (123 loc) · 3.11 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
stages:
- test
- build
- staging
- production
variables:
TAG_LATEST: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
TAG_COMMIT: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA
include:
- template: Dependency-Scanning.gitlab-ci.yml
- template: Security/SAST.gitlab-ci.yml
- template: Security/License-Scanning.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
- template: Code-Quality.gitlab-ci.yml
test:jsonvalidation:
stage: test
image: node:14.15-buster
allow_failure: false
tags:
- docker
before_script:
- npm install -g ajv-cli ajv-formats
- cd ./src/data
script:
- ajv test -s schemas/country.schema -d "countries/*.json" -c ajv-formats --valid --verbose --all-errors
only:
changes:
- src/data/**/*
test:karma:
stage: test
image: node:14.15-buster
allow_failure: false
tags:
- docker
before_script:
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
- echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
- DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install google-chrome-stable -y -qq
script:
- yarn
- ./node_modules/@angular/cli/bin/ng test --browsers=ChromeHeadlessCI --no-watch --no-progress
only:
changes:
- src/**/*
- ./*.json
- yarn.lock
- .editorconfig
- .browserslistrc
code_quality:
artifacts:
paths: [gl-code-quality-report.json]
build:
stage: build
image: docker:latest
tags:
- docker
services:
- docker:dind
before_script:
- sed -ri "s|"VERSION"|"$CI_COMMIT_SHORT_SHA"|" src/environments/environment.prod.ts
- sed -ri "s|"VERSION"|"$CI_COMMIT_SHORT_SHA"|" src/environments/environment.server.ts
- sed -ri "s|"VERSION"|"$CI_COMMIT_SHORT_SHA"|" src/environments/environment.ts
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- DOCKER_BUILDKIT=1 docker build --cache-from=registry.gitlab.com/mobilespectrum/mobilespectrum/main:latest -t $TAG_COMMIT -t $TAG_LATEST .
- docker push $TAG_COMMIT
- docker push $TAG_LATEST
- docker logout
only:
refs:
- main
deploy:stage:
stage: staging
image: alpine:latest
tags:
- docker
environment:
name: stage
url: https://stage.mobilespectrum.org
before_script:
- apk add --no-cache curl
script:
- echo "Deploying $CI_COMMIT_SHA to stage"
- curl -X POST $DEPLOY_STAGE
only:
refs:
- main
variables:
- $DEPLOY_STAGE
deploy:production:
stage: production
image: alpine:latest
tags:
- docker
environment:
name: production
url: https://mobilespectrum.org
before_script:
- apk add --no-cache curl
script:
- echo "Deploying $CI_COMMIT_SHA to production"
- curl -X POST $DEPLOY_PROD
only:
refs:
- main
variables:
- $DEPLOY_PROD
when: manual
allow_failure: false
pages:
image: node:14.15-alpine
before_script:
- npm install -g @compodoc/compodoc
script:
- npx compodoc -p tsconfig.json -d public -n "MobileSpectrum Documentation" src
artifacts:
paths:
- public
only:
refs:
- main
variables:
- $DEPLOY_PROD