-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
144 lines (129 loc) · 3.96 KB
/
.gitlab-ci.yml
File metadata and controls
144 lines (129 loc) · 3.96 KB
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
variables:
LC_ALL: 'en_US.UTF-8'
LANG: 'en_US.UTF-8'
stages:
- release_android
- release_ios
- build_web
- deploy_web
- clear_web
.build:
stage: build_web
tags:
- docker
image: docker:latest
services:
- docker:dind
.doctl:
tags:
- docker
image:
name: digitalocean/doctl:latest
entrypoint: ['']
services:
- docker:dind
# Android
release_android:
stage: release_android
tags:
- shell
artifacts:
paths:
- app/android/app/build/outputs/
only:
- /^release\/android-.+$/
script:
# Create stage variables:
- name=${CI_COMMIT_REF_NAME/release\//} # "android-dev" or "android-release"
- postfix=${name/android-/} # "dev" or "release"
- prefix=$(echo $postfix | tr '[:lower:]' '[:upper:]' | awk '{print $1"_"}') # "DEV_" or "PROD_"
# Creating `.env` configuration file:
- dump-env -p "APP_${prefix}" -p "APP_${prefix}" > app/.env.$postfix
- echo $KEYSTORE | base64 -d > app/android/app.keystore
- echo $PLAY_CONSOLE | base64 -d > app/android/play_console.json
# Install packages:
- cd app
- yarn install
- bundle install
# Build app:
- cd ./fastlane
- bundle exec fastlane android beta --env $postfix
# IOS
release_ios:
stage: release_ios
tags:
- shell
only:
- /^release\/ios-.+$/
artifacts:
expire_in: 1 day
when: on_failure
public: false
paths:
- app/fastlane/ios-build.log
script:
# Create stage variables:
- name=${CI_COMMIT_REF_NAME/release\//} # "ios-dev" or "ios-prod"
- postfix=${name/ios-/} # "dev" or "prod"
- prefix=$(echo $postfix | tr '[:lower:]' '[:upper:]' | awk '{print $1"_"}') # "DEV_" or "PROD_"
# Creating `.env` configuration file:
- pip3 install dump-env
- dump-env -p "APP_${prefix}" -p "APP_${prefix}" > app/.env.$postfix
- dump-env -p 'APPLE_' > app/fastlane/.env
# Install packages:
- cd app
- yarn install
- bundle install
# Build app:
- cd ./fastlane
- bundle exec fastlane ios beta --env $postfix
build_web:
extends: .build
only:
- /^release\/web-.+$/
script:
# Variables:
- name=${CI_COMMIT_REF_NAME/release\//} # "web-dev" or "web-prod"
- postfix=${name/web-/} # "dev" or "prod"
- prefix=$(echo $postfix | tr '[:lower:]' '[:upper:]' | awk '{print $1"_"}') # "DEV_" or "PROD_"
# Installing global dependencies:
- apk update && apk upgrade
- apk add py3-pip
- pip3 install dump-env
- cd web
- dump-env -p "WEB_${prefix}" > .env
- DOCKER_BUILDKIT=1 docker build --platform linux/amd64 -t $CI_REGISTRY_IMAGE/completely:$postfix .
- docker tag $CI_REGISTRY_IMAGE/completely:$postfix registry.digitalocean.com/completely/web:$postfix
- docker login -u $$DIGITALOCEAN_ACCESS_TOKEN -p $$DIGITALOCEAN_ACCESS_TOKEN registry.digitalocean.com
- docker push registry.digitalocean.com/completely/web:$postfix
deploy_web:
stage: deploy_web
extends: .doctl
only:
- /^release\/web-.+$/
script:
# Variables:
- name=${CI_COMMIT_REF_NAME/release\//} # "web-dev" or "web-prod"
- postfix=${name/web-/} # "dev" or "prod"
- prefix=$(echo $postfix | tr '[:lower:]' '[:upper:]' | awk '{print $1"_"}') # "DEV_" or "PROD_"
- app_id_name="WEB_${prefix}DIGITALOCEAN_APP_ID"
- app_id=$(eval echo "\$${app_id_name}" | awk '{print $1}')
- /app/doctl auth init -t $$DIGITALOCEAN_ACCESS_TOKEN
- /app/doctl apps create-deployment $app_id
clear:
extends: .doctl
stage: clear_web
only:
refs:
- schedules
variables:
- $SCHEDULE_TYPE == "clear"
script:
# Installing global dependencies:
- apk update && apk upgrade
- apk add jq
# Clear:
- /app/doctl registry login -t $DIGITALOCEAN_ACCESS_TOKEN
- /app/doctl registry repo delete-manifest web $(doctl registry repository list-manifests web --output json | jq ".[] | select (.tags == null) | .digest" -r | tr '\n' ' ') -f
- /app/doctl registry garbage-collection start -f
- /app/doctl registry logout