-
-
Notifications
You must be signed in to change notification settings - Fork 738
207 lines (185 loc) · 6.57 KB
/
deploy.yml
File metadata and controls
207 lines (185 loc) · 6.57 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
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: Build / Deploy
on:
workflow_dispatch:
inputs:
mode:
description: "Workflow mode"
type: choice
options:
- deploy
- build
required: true
default: deploy
env:
description: "Build environment; used only when mode=build"
type: choice
options:
- dev
- prod
required: true
default: dev
backend_mode:
description: "Backend package build mode; in never mode, backend-only coins still build backend packages"
type: choice
options:
- auto
- always
- never
required: true
default: auto
coins:
description: "Comma-separated coin aliases from configs/coins; ALL is supported only in build mode"
required: true
branch_or_tag:
description: "Branch or tag to check out and deploy (leave empty for current ref)"
required: false
default: ""
permissions:
contents: read
jobs:
prepare_build:
name: Prepare Build Plan
runs-on: ubuntu-latest
if: ${{ inputs.mode == 'build' }}
env:
RESOLVED_BRANCH_OR_TAG: ${{ inputs.branch_or_tag != '' && inputs.branch_or_tag || github.ref_name }}
outputs:
runner_matrix: ${{ steps.plan.outputs.runner_matrix }}
coins_csv: ${{ steps.plan.outputs.coins_csv }}
steps:
- name: Checkout workflow code
uses: actions/checkout@v4
- name: Validate branch or tag
run: python3 ./.github/scripts/validate_branch_or_tag.py --repo "${{ github.repository }}" --ref "${{ env.RESOLVED_BRANCH_OR_TAG }}"
- name: Checkout requested branch or tag
uses: actions/checkout@v4
with:
ref: ${{ env.RESOLVED_BRANCH_OR_TAG }}
- name: Build build plan
id: plan
env:
VARS_JSON: ${{ toJSON(vars) }}
COINS_INPUT: ${{ inputs.coins }}
BUILD_ENV: ${{ inputs.env }}
run: python3 ./.github/scripts/build_plan.py
prepare_deploy:
name: Prepare Deploy Plan
runs-on: ubuntu-latest
if: ${{ inputs.mode == 'deploy' }}
env:
RESOLVED_BRANCH_OR_TAG: ${{ inputs.branch_or_tag != '' && inputs.branch_or_tag || github.ref_name }}
outputs:
runner_matrix: ${{ steps.plan.outputs.runner_matrix }}
e2e_regex: ${{ steps.plan.outputs.e2e_regex }}
coins_csv: ${{ steps.plan.outputs.coins_csv }}
test_coins_csv: ${{ steps.plan.outputs.test_coins_csv }}
steps:
- name: Checkout workflow code
uses: actions/checkout@v4
- name: Validate branch or tag
run: python3 ./.github/scripts/validate_branch_or_tag.py --repo "${{ github.repository }}" --ref "${{ env.RESOLVED_BRANCH_OR_TAG }}"
- name: Checkout requested branch or tag
uses: actions/checkout@v4
with:
ref: ${{ env.RESOLVED_BRANCH_OR_TAG }}
- name: Build deploy/e2e plan
id: plan
env:
VARS_JSON: ${{ toJSON(vars) }}
COINS_INPUT: ${{ inputs.coins }}
run: python3 ./.github/scripts/deploy_plan.py
build:
name: Build (${{ matrix.runner }})
needs: prepare_build
if: ${{ inputs.mode == 'build' }}
env:
RESOLVED_BRANCH_OR_TAG: ${{ inputs.branch_or_tag != '' && inputs.branch_or_tag || github.ref_name }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.prepare_build.outputs.runner_matrix || '[]') }}
runs-on: ${{ fromJSON(matrix.labels_json) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.RESOLVED_BRANCH_OR_TAG }}
- name: Export repository variables
uses: ./.github/actions/export-env-vars
with:
vars_json: ${{ toJSON(vars) }}
- name: Build packages
env:
BRANCH_OR_TAG: ${{ env.RESOLVED_BRANCH_OR_TAG }}
BB_PACKAGE_ROOT: /opt/blockbook-builds
BB_BUILD_ENV: ${{ inputs.env }}
run: python3 ./.github/scripts/build_packages.py --backend-mode ${{ inputs.backend_mode }} ${{ join(matrix.coins, ' ') }}
deploy:
name: Deploy (${{ matrix.coin }})
needs: prepare_deploy
if: ${{ inputs.mode == 'deploy' }}
env:
RESOLVED_BRANCH_OR_TAG: ${{ inputs.branch_or_tag != '' && inputs.branch_or_tag || github.ref_name }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.prepare_deploy.outputs.runner_matrix || '[]') }}
runs-on: [self-hosted, bb-dev-selfhosted, "${{ matrix.runner }}"]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.RESOLVED_BRANCH_OR_TAG }}
- name: Export repository variables
uses: ./.github/actions/export-env-vars
with:
vars_json: ${{ toJSON(vars) }}
- name: Deploy blockbook package
env:
BRANCH_OR_TAG: ${{ env.RESOLVED_BRANCH_OR_TAG }}
BB_BUILD_ENV: dev
run: ./contrib/scripts/deploy-bb-and-backend.sh "${{ matrix.coin }}" --force-confnew
wait-for-sync:
name: Wait For Sync
needs: [prepare_deploy, deploy]
if: ${{ needs.deploy.result == 'success' }}
runs-on: [self-hosted, bb-dev-selfhosted]
timeout-minutes: 31
env:
RESOLVED_BRANCH_OR_TAG: ${{ inputs.branch_or_tag != '' && inputs.branch_or_tag || github.ref_name }}
COINS_INPUT: ${{ needs.prepare_deploy.outputs.test_coins_csv }}
SYNC_TIMEOUT_SECONDS: "1800"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.RESOLVED_BRANCH_OR_TAG }}
- name: Export repository variables
uses: ./.github/actions/export-env-vars
with:
vars_json: ${{ toJSON(vars) }}
- name: Wait for Blockbook sync
env:
BB_BUILD_ENV: dev
run: python3 ./.github/scripts/wait_for_sync.py
e2e-tests:
name: E2E Tests (post-deploy)
needs: [prepare_deploy, deploy, wait-for-sync]
if: ${{ needs.deploy.result == 'success' && needs.wait-for-sync.result == 'success' }}
runs-on: [self-hosted, bb-dev-selfhosted]
env:
RESOLVED_BRANCH_OR_TAG: ${{ inputs.branch_or_tag != '' && inputs.branch_or_tag || github.ref_name }}
E2E_REGEX: ${{ needs.prepare_deploy.outputs.e2e_regex }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.RESOLVED_BRANCH_OR_TAG }}
- name: Export repository variables
uses: ./.github/actions/export-env-vars
with:
vars_json: ${{ toJSON(vars) }}
- name: Run e2e tests
env:
BB_BUILD_ENV: dev
run: make test-e2e ARGS="-v"