-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
150 lines (143 loc) · 4.6 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
stages:
- docker
- dependencies
- build
- deploy
docker-build:
stage: docker
image: docker:latest
services:
- docker:dind # requirement for docker build
rules:
- changes: # build if change in Docker image
- docker/image/*
when: always
- when: never # else never perform this job
script:
- docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- docker pull $CI_REGISTRY_IMAGE:latest || true
- >
docker build
-t $CI_REGISTRY_IMAGE:latest
./docker/image
- docker push $CI_REGISTRY_IMAGE:latest
.npm-template: &npm-template
stage: dependencies
image: $CI_REGISTRY_IMAGE:latest
cache:
key: ${CI_COMMIT_REF_SLUG} # don't share cache between branches
paths:
- node_modules/
- functions/node_modules/
- /usr/local/lib/node_modules/
npm-install:
<<: *npm-template
rules:
- if: '$CI_MERGE_REQUEST_ID != null || $CI_COMMIT_REF_NAME == "master"'
when: never # never perform this job on master or merge request
- exists: # perform the job if nodes modules exists and there is a change in package.json or package-lock.json
- node_modules
changes:
- package.json
- package-lock.json
- functions/package.json
- functions/package-lock.json
when: on_success
- exists: # if node_modules exists and the previous rule did not trigger, skip this job
- node_modules
when: never
- when: on_success # if none of the previous rules triggered, perform the job
script:
- npm install
- cd functions
- npm install
- yes | /opt/android-sdk/tools/bin/sdkmanager --licenses || true
npm-ci:
<<: *npm-template
rules:
- if: '$CI_MERGE_REQUEST_ID == null && $CI_COMMIT_REF_NAME != "master"'
when: never # never perform this job on a branch
- exists: # perform the job if nodes modules exists and there is a change in package.json or package-lock.json
- node_modules
changes:
- package.json
- package-lock.json
- functions/package.json
- functions/package-lock.json
when: on_success
- exists: # if node_modules exists and the previous rule did not trigger, skip this job
- node_modules
when: never
- when: on_success # if none of the previous rules triggered, perform the job
script:
- npm ci
- cd functions
- npm ci
- yes | /opt/android-sdk/tools/bin/sdkmanager --licenses || true
firebase:
stage: build
image: $CI_REGISTRY_IMAGE:latest
rules:
- when: on_success # this statement in required not to fall back in the default only: [branch, tags]
cache:
key: ${CI_COMMIT_REF_SLUG} # don't share cache between branches
policy: pull
paths:
- ./* # pull everything that is in the cache
script:
- ionic build --prod
artifacts:
expire_in: 1 day # we do not want to keep these artifacts, they are just needed for the deploy job
paths:
- firestore.indexes.json
- public/
- storage.rules
- www/
cordova:
stage: build
image: $CI_REGISTRY_IMAGE:latest
rules:
- when: on_success # this statement in required not to fall back in the default only: [branch, tags]
cache:
key: ${CI_COMMIT_REF_SLUG} # don't share cache between branches
policy: pull # no need to push the cache
paths:
- ./*
script:
- ionic cordova platform add android
- ionic cordova build android --prod --release
- >
jarsigner -verbose
-sigalg SHA1withRSA
-digestalg SHA1
-keystore resources/certs/android-release-key.jks
platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk
wadaff
-storepass $KEYSTORE_PASS
- cd platforms/android/app/build/outputs/apk/release/
- $ANDROID_SDK_ROOT/build-tools/$ANDROID_BUILD_TOOLS_VERSION/zipalign 4 app-release-unsigned.apk Wadaff.apk
- $ANDROID_SDK_ROOT/build-tools/$ANDROID_BUILD_TOOLS_VERSION/apksigner verify Wadaff.apk
artifacts:
paths:
- platforms/android/app/build/outputs/apk/release/Wadaff.apk
# Deploy only if we are on master
deploy:
stage: deploy
image: $CI_REGISTRY_IMAGE:latest
cache:
key: ${CI_COMMIT_REF_SLUG} # don't share cache between branches
policy: pull # no need to push the cache
paths:
- ./*
rules:
- if: '$CI_COMMIT_REF_NAME == "master"'
when: on_success
dependencies: ["firebase"] # get the artifact of firebase
needs: ["firebase"] # do not wait for other jobs than firebase
script:
- firebase use default
- firebase deploy --token $FIREBASE_TOKEN
artifacts:
paths:
- /root/.npm/_logs/*
when: on_failure