-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
173 lines (157 loc) · 4.98 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
---
# == Notes ==
# This CI definition uses a GitLab provided include template
# GitLab automatically passes artifacts from previous stages by default
# Secret variables
# - Set required secret variables at: https://gitlab.data.bas.ac.uk/MAGIC/SIIS/-/settings/ci_cd
# - Variables are grouped by section in KEY: "value" format (e.g. FOO: "bar")
# Sensitive values are represented by "[Sensitive]"
#
# ...
#
# Changes and tags
# - most jobs in this pipeline use 'changes' rules to run jobs only when certain components have been updated
# - when a pipeline is created for a new tag (as part of a release), changes rules will always evaluate to true and run
# - see https://docs.gitlab.com/ee/ci/yaml/README.html#ruleschanges for further details
# == Includes ==
include:
- template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
# == Global settings ==
stages:
- 🧪 test
- 🏗 build
- 📦 package
- 🚚 distribute
- 🐳 containerise
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_CERT_PATH: /certs/client
DOCKER_DRIVER: overlay2
DOCKER_TLS_VERIFY: 1
GITLAB_REGISTRY: docker-registry.data.bas.ac.uk
# == Jobs ==
black:
stage: 🧪 test
image:
name: docker-registry.data.bas.ac.uk/magic/siis/api:latest
entrypoint: [""]
script:
- "black --check api/"
needs: []
rules:
- changes:
- 'api/**/*.*'
build-app-stage:
stage: 🏗 build
image:
name: docker-registry.data.bas.ac.uk/magic/siis/app:latest
entrypoint: [""]
variables:
SERVICE_API_ENDPOINT: https://api.siis.sda-stage.bas.ac.uk
SERVICE_API_KV_ENDPOINT: http://10.70.1.145:32003/kv
SERVICE_API_OGC_ENDPOINT: https://geoserver.siis.sda-stage.bas.ac.uk
before_script:
- 'cd app'
- 'yarn install'
script:
- "yarn build"
needs: []
artifacts:
paths:
- app/dist
expire_in: 1 month
rules:
- changes:
- 'app/**/*.*'
build-app-prod:
stage: 🏗 build
image:
name: docker-registry.data.bas.ac.uk/magic/siis/app:latest
entrypoint: [""]
variables:
SERVICE_API_ENDPOINT: https://api.siis.sda.bas.ac.uk
SERVICE_API_KV_ENDPOINT: http://10.70.1.145:32003/kv
SERVICE_API_OGC_ENDPOINT: https://geoserver.siis.sda.bas.ac.uk
before_script:
- 'cd app'
- 'yarn install'
script:
- "yarn build"
needs: []
artifacts:
paths:
- app/dist
expire_in: 1 month
rules:
-
changes:
- 'app/**/*.*'
if: $CI_COMMIT_TAG
package-app-stage:
stage: 📦 package
image:
name: alpine:latest
entrypoint: [""]
before_script:
- "apk add --no-cache zip"
- "mkdir -p ./app/dist-pkgs/"
- "cd ./app/dist/"
script:
- "zip ../dist-pkgs/app-stage.zip *"
- "zip ../dist-pkgs/app-stage-no-src-maps.zip * -x '*.map*'"
artifacts:
paths:
- app/dist-pkgs
expire_in: 1 month
needs:
- job: build-app-stage
artifacts: true
rules:
- changes:
- 'app/**/*.*'
package-app-prod:
stage: 📦 package
image:
name: alpine:latest
entrypoint: [""]
before_script:
- "apk add --no-cache zip"
- "mkdir -p ./app/dist-pkgs/"
- "cd ./app/dist/"
script:
- "zip ../dist-pkgs/app-prod.zip *"
- "zip ../dist-pkgs/app-prod-no-src-maps.zip * -x '*.map*'"
artifacts:
paths:
- app/dist-pkgs
expire_in: 1 month
needs:
- job: build-app-prod
artifacts: true
rules:
-
changes:
- 'app/**/*.*'
if: $CI_COMMIT_TAG
distribute-app:
stage: 🚚 distribute
image:
name: curlimages/curl:latest
entrypoint: [""]
before_script:
# we need to remove the `v` prefix for the tag because GitLab only allows package versions in the form `1.2.3`
# see https://gitlab.com/gitlab-org/gitlab/-/issues/273034 for details
- "export PACKAGE_VERSION=$(echo $CI_COMMIT_TAG | sed 's/^v//')"
script:
# if these commands fail, remove the `--fail` flag to re-enable response output, this flag is normally on to fail this job on a non-200 status code, annoyingly you can't have both behaviours
- 'curl --fail --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ./app/dist-pkgs/app-stage.zip ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/app/$PACKAGE_VERSION/app-$PACKAGE_VERSION-stage.zip'
- 'curl --fail --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ./app/dist-pkgs/app-stage-no-src-maps.zip ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/app/$PACKAGE_VERSION/app-$PACKAGE_VERSION-stage-no-src-maps.zip'
- 'curl --fail --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ./app/dist-pkgs/app-prod.zip ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/app/$PACKAGE_VERSION/app-$PACKAGE_VERSION-prod.zip'
- 'curl --fail --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ./app/dist-pkgs/app-prod-no-src-maps.zip ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/app/$PACKAGE_VERSION/app-$PACKAGE_VERSION-prod-no-src-maps.zip'
needs:
- job: package-app-stage
artifacts: true
- job: package-app-prod
artifacts: true
rules:
- if: $CI_COMMIT_TAG