-
Notifications
You must be signed in to change notification settings - Fork 68
/
.gitlab-ci.yml
156 lines (140 loc) · 3.88 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
# ---------------------------------------------------------------
# Global
# ---------------------------------------------------------------
# default image
image: node:12
# stages (main steps of pipeline)
stages:
- build
- alt_build
- deploy
# ---------------------------------------------------------------
# Global variables
# ---------------------------------------------------------------
variables:
CI_BUILD_IMAGE: $CI_REGISTRY_IMAGE/build:develop
# ---------------------------------------------------------------
# Jobs templates
# ---------------------------------------------------------------
.docker:
image: docker:latest
tags: [redshift]
services:
- docker:dind
before_script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
#- docker login -u "duniterteam" -p "$DUNITERTEAM_PASSWD"
after_script:
- docker logout ${CI_REGISTRY}
#- docker logout
allow_failure: false
# ---------------------------------------------------------------
# Build jobs
# ---------------------------------------------------------------
.build:
stage: build
tags: [redshift]
script:
- yarn install
- yarn run build:web
after_script:
- ls -la dist/web/
- du -csh dist/web/
artifacts:
untracked: true
paths:
- dist/web
expire_in: 60 minutes
build:
extends: .build
image: ${CI_BUILD_IMAGE}
before_script:
- mv /tmp/.build-cache/node_modules ./
only:
- develop
failsafe-build:
extends: .build
stage: alt_build
when: on_failure
before_script:
- yarn global add gulp
only:
- develop
docker:ci:
extends: .docker
stage: alt_build
when: on_failure
allow_failure: true
script:
# Create the target directory
- mkdir -p dist/ci
- cd dist/ci
# Create the Dockerfile
- echo 'FROM node:12' > Dockerfile
- echo 'WORKDIR /tmp/.build-cache' >> Dockerfile
- echo 'COPY ./ ./' >> Dockerfile
# Store disk usage (before install)
- echo 'RUN du -s `find . -maxdepth 1 | egrep -v "^\.$"` > /tmp/before.txt' >> Dockerfile
- echo 'RUN du -s `find /tmp/.cache/yarn -maxdepth 1 | egrep -v "^\.$"` >> /tmp/before.txt' >> Dockerfile
# Install dependencies
- echo 'RUN yarn global add gulp web-ext @ionic/cli' >> Dockerfile
- echo 'RUN yarn install' >> Dockerfile
# Store disk usage (after install)
- echo 'RUN du -s `find . -maxdepth 1 | egrep -v "^\.$"` > /tmp/after.txt' >> Dockerfile
- echo 'RUN du -s `find /tmp/.cache/yarn -maxdepth 1 | egrep -v "^\.$"` >> /tmp/after.txt' >> Dockerfile
# Force docker to detect any changes
- echo "RUN diff /tmp/before.txt /tmp/after.txt || true" >> Dockerfile
- echo 'WORKDIR /build' >> Dockerfile
# Build and push the CI image
- docker build --no-cache -t ${CI_BUILD_IMAGE} .
- docker push ${CI_BUILD_IMAGE}
artifacts:
paths:
- dist/ci/Dockerfile
expire_in: 60 minutes
# ---------------------------------------------------------------
# Deploy jobs
# ---------------------------------------------------------------
pages:
stage: deploy
variables:
GIT_STRATEGY: none
script:
- ls -la public || true
- mv dist/web/www public
artifacts:
untracked: true
paths:
- public
only:
- master
mirror:
stage: deploy
image: liaohuqiu/rsync
before_script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- >-
[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >
~/.ssh/config
script:
- mv dist/web/www public
- rsync -az -e ssh ./public/ gammanu@1000i100.fr:~/g1.money/dev-cesium
after_script:
- ssh gammanu@1000i100.fr "~/g1.money/update-cesium.sh"
only:
- master
release:
stage: deploy
variables:
GIT_STRATEGY: none
script:
- ls -la www || true
- mv dist/web/www www
artifacts:
untracked: true
paths:
- www
only:
- tags