This repository has been archived by the owner on Mar 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 148
/
bitrise.yml
186 lines (163 loc) · 5.05 KB
/
bitrise.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
174
175
176
177
178
179
180
181
182
183
184
185
186
---
format_version: 1.1.0
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
app:
envs:
- DOCKERHUB_IMG_ID_ALPHA: bitriseio/docker-android-alpha
- DOCKERHUB_IMG_ID_PINNED: bitriseio/docker-android
- DOCKER_FILE_PATH_ALPHA: ./Dockerfile
- DOCKER_FILE_PATH_PINNED: ./Dockerfile-pinned
#
- DOCKERHUB_IMG_ID: $DOCKERHUB_IMG_ID_ALPHA
- DOCKER_FILE_PATH: $DOCKER_FILE_PATH_ALPHA
# define in .bitrise.secrets.yml
- DOCKER_LOGIN_USER: $DOCKER_LOGIN_USER
- DOCKER_LOGIN_PASS: $DOCKER_LOGIN_PASS
# on CI
- SLACK_WEBHOOK_URL: $SLACK_WEBHOOK_URL
- SLACK_CHANNEL: $SLACK_CHANNEL
# Quay
- QUAY_IMG_ID: quay.io/bitriseio/android
- QUAY_LOGIN_USER: $QUAY_LOGIN_USER
- QUAY_LOGIN_PASS: $QUAY_LOGIN_PASS
- IS_ALPHA: "true"
# optional
- CONFIG_do_not_deploy_latest_tag: $CONFIG_do_not_deploy_latest_tag
workflows:
#
# Main workflows
#
# -- Rebuild / test
rebuild-pinned:
before_run:
- _pinned_envs
after_run:
- _rebuild
rebuild-alpha:
before_run:
- _alpha_envs
after_run:
- _rebuild
# -- Deploy
deploy-pinned:
before_run:
- _pinned_envs
after_run:
- _deploy
deploy-alpha:
before_run:
- _alpha_envs
after_run:
- _deploy
#
# Utility workflows
#
_rebuild:
steps:
- script@1.1.0:
title: docker prune previous image versions
inputs:
- content: |
#!/usr/bin/env bash
set -ex
# Docker filter does not match slashes (on a purpose)
# https://github.com/moby/moby/issues/36196
# Therefore, grep / awk magic will be used here
# The following will capture both android and android-ndk[-lts] images
docker rmi -f $(docker images | grep -E 'bitriseio/android' | awk '{print $1 ":" $2}')
- script@1.1.0:
title: docker infos & images
inputs:
- content: |
#!/bin/bash
set -ex
docker images
df -kh ./
docker info
- script@1.1.0:
title: docker build
inputs:
- content: |
#!/bin/bash
set -ex
docker build --pull --no-cache -t "${DOCKERHUB_IMG_ID}:latest" --file "${DOCKER_FILE_PATH}" .
docker images
_pinned_envs:
envs:
- DOCKERHUB_IMG_ID: $DOCKERHUB_IMG_ID_PINNED
- DOCKER_FILE_PATH: $DOCKER_FILE_PATH_PINNED
- IS_ALPHA: "false"
_alpha_envs:
envs:
- DOCKERHUB_IMG_ID: $DOCKERHUB_IMG_ID_ALPHA
- DOCKER_FILE_PATH: $DOCKER_FILE_PATH_ALPHA
- IS_ALPHA: "true"
_generate_image_deploy_tag:
steps:
- script:
inputs:
- content: |
#!/bin/bash
set -ex
envman add --key 'DOCKER_IMAGE_DEPLOY_TAG' --value "v$(date +%Y_%m_%d-%H_%M)-b${BITRISE_BUILD_NUMBER}"
_deploy:
before_run:
- _generate_image_deploy_tag
- _rebuild
steps:
- script@1.1.0:
title: docker login
inputs:
- content: |
#!/bin/bash
set -e
echo "=> Docker login..."
docker login -u "${DOCKER_LOGIN_USER}" -p "${DOCKER_LOGIN_PASS}"
echo "=> Quay.io login..."
docker login -u "${QUAY_LOGIN_USER}" -p "${QUAY_LOGIN_PASS}" quay.io
- script@1.1.0:
title: docker push
inputs:
- content: |
#!/bin/bash
set -ex
if [ -z "${DOCKER_IMAGE_DEPLOY_TAG}" ] ; then
echo " [!] No DOCKER_IMAGE_DEPLOY_TAG specified!"
exit 1
fi
### Tags
# Docker Hub
docker tag "${DOCKERHUB_IMG_ID}:latest" "${DOCKERHUB_IMG_ID}:${DOCKER_IMAGE_DEPLOY_TAG}"
# Quay.io
if [[ "${IS_ALPHA}" == "true" ]]; then
image_tag="alpha-${DOCKER_IMAGE_DEPLOY_TAG}"
latest_image_tag="alpha"
else
image_tag="${DOCKER_IMAGE_DEPLOY_TAG}"
latest_image_tag="latest"
fi
docker tag "${DOCKERHUB_IMG_ID}:latest" "${QUAY_IMG_ID}:${image_tag}"
docker tag "${DOCKERHUB_IMG_ID}:latest" "${QUAY_IMG_ID}:${latest_image_tag}"
### Push
# Docker Hub
docker push "${DOCKERHUB_IMG_ID}:${DOCKER_IMAGE_DEPLOY_TAG}"
docker push "${DOCKERHUB_IMG_ID}:latest"
# Quay.io
docker push "${QUAY_IMG_ID}:${image_tag}"
docker push "${QUAY_IMG_ID}:${latest_image_tag}"
- slack@2.1.0:
run_if: '{{.IsCI | and .IsBuildFailed}}'
inputs:
- webhook_url: $SLACK_WEBHOOK_URL
- channel: $SLACK_CHANNEL
- from_username: "$BITRISE_APP_TITLE - OK"
- from_username_on_error: "$BITRISE_APP_TITLE - ERROR"
- message: |
Finished:
- Branch: *$BITRISE_GIT_BRANCH*
- Tag: $BITRISE_GIT_TAG
- Image ID: $DOCKERHUB_IMG_ID
- Image tag: $DOCKER_IMAGE_DEPLOY_TAG
- Build URL: $BITRISE_BUILD_URL
- Build Number: $BITRISE_BUILD_NUMBER
- Build Message: $BITRISE_GIT_MESSAGE