-
Notifications
You must be signed in to change notification settings - Fork 0
225 lines (207 loc) · 7.58 KB
/
dapp-deploy.yml
File metadata and controls
225 lines (207 loc) · 7.58 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: deploy-dapp
on:
workflow_dispatch:
inputs:
environment:
description: 'Deployment environment'
required: true
type: choice
options:
# dev environments
- bellecour-dev
- arbitrum-sepolia-dev
# prod environments (requires a tag starting with dapp-v)
- bellecour-prod
- arbitrum-sepolia-prod
- arbitrum-prod
jobs:
extract-tag:
runs-on: ubuntu-latest
outputs:
clean_tag: ${{ steps.tag.outputs.clean_tag }}
steps:
- name: Checkout code
uses: actions/checkout@v4
# ref should be a tag beginning with dapp-v if not exit error
# use unique clean-tag: <tag>-<timestamp>
# else
# use rolling clean-tag: dev
- name: Check and extract tag
id: tag
run: |
if [[ "${{ github.event.inputs.environment }}" == *-prod ]]; then
if [[ "${GITHUB_REF}" != refs/tags/dapp-v* ]]; then
echo "Error: The ref must be a tag starting with 'dapp-v' for production deployments."
exit 1
fi
TAG=${GITHUB_REF#refs/tags/dapp-v}-$(date +%s)
echo "clean_tag=${TAG}" | tee -a $GITHUB_OUTPUT
else
echo "clean_tag=dev" | tee -a $GITHUB_OUTPUT
fi
docker-publish:
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/docker-build.yml@docker-build-v3.3.0
needs: [extract-tag]
with:
image-name: 'iexechub/web3telegram-dapp'
registry: 'docker.io'
dockerfile: 'dapp/Dockerfile'
context: 'dapp'
security-scan: false
hadolint: true
push: true
image-tag: ${{ needs.extract-tag.outputs.clean_tag }}
secrets:
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-password: ${{ secrets.DOCKERHUB_PAT }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PAT }}
sconify:
if: startsWith(github.event.inputs.environment, 'bellecour-')
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/sconify.yml@sconify-v2.0.0
needs: [docker-publish, extract-tag]
with:
image-name: 'iexechub/web3telegram-dapp'
image-tag: ${{ needs.extract-tag.outputs.clean_tag }}
sconify-debug: false
sconify-prod: true
docker-registry: docker.io
sconify-version: ${{ vars.SCONIFY_VERSION }}
binary: /usr/local/bin/node
command: node
host-path: |
/etc/hosts
/etc/resolv.conf
binary-fs: true
fs-dir: /app
heap: 1G
dlopen: 1
mprotect: 0
secrets:
docker-username: ${{ secrets.DOCKERHUB_USERNAME }}
docker-password: ${{ secrets.DOCKERHUB_PAT }}
scontain-username: ${{ secrets.SCONTAIN_REGISTRY_USERNAME }}
scontain-password: ${{ secrets.SCONTAIN_REGISTRY_PAT }}
scone-signing-key: ${{ secrets.SCONIFY_SIGNING_PRIVATE_KEY }}
deploy-tdx-dapp:
if: startsWith(github.event.inputs.environment, 'arbitrum-')
needs: [extract-tag, docker-publish]
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.19.0'
cache: 'npm'
- name: Install dependencies
run: |
npm ci
cd node_modules/whitelist-smart-contract
npm install --save-dev ts-node
cd ../../deployment-dapp
npm ci
- name: Deploy TDX dapp contract
env:
WALLET_PRIVATE_KEY: ${{ secrets.WEB3TELEGRAM_APP_OWNER_PRIVATEKEY }}
DOCKER_IMAGE_TAG: ${{ needs.extract-tag.outputs.clean_tag }}
CHECKSUM: ${{ needs.docker-publish.outputs.checksum }}
RPC_URL: ${{ secrets.RPC_URL }}
run: |
cd deployment-dapp
npm run deploy-dapp
- name: Push dapp secret
env:
WALLET_PRIVATE_KEY: ${{ secrets.WEB3TELEGRAM_APP_OWNER_PRIVATEKEY }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
RPC_URL: ${{ secrets.RPC_URL }}
run: |
cd deployment-dapp
npm run push-dapp-secret
- name: Publish free sell order
env:
WALLET_PRIVATE_KEY: ${{ secrets.WEB3TELEGRAM_APP_OWNER_PRIVATEKEY }}
PRICE: ${{ vars.SELL_ORDER_PRICE }}
VOLUME: ${{ vars.SELL_ORDER_VOLUME }}
RPC_URL: ${{ secrets.RPC_URL }}
TEE_FRAMEWORK: ${{ vars.TEE_FRAMEWORK }}
run: |
cd deployment-dapp
npm run publish-sell-order
- name: Add resource to whitelist
env:
CONTRACT_ADDRESS: ${{ vars.WEB3TELEGRAM_WHITELIST_CONTRACT_ADDRESS }}
PRIVATE_KEY: ${{ secrets.WEB3TELEGRAM_APP_OWNER_PRIVATEKEY }}
RPC_URL: ${{ secrets.RPC_URL }}
run: |
cd node_modules/whitelist-smart-contract
export ADDRESS_TO_ADD=$(cat ../../deployment-dapp/.app-address)
npm run addResourceToWhitelist -- --network ${{ vars.WHITELIST_NETWORK_NAME }}
deploy-scone-dapp:
if: startsWith(github.event.inputs.environment, 'bellecour-')
needs: [extract-tag, sconify]
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: |
npm ci
cd node_modules/whitelist-smart-contract
npm install --save-dev ts-node
cd ../../deployment-dapp
npm ci
- name: Deploy SCONE dapp contract
env:
WALLET_PRIVATE_KEY: ${{ secrets.WEB3TELEGRAM_APP_OWNER_PRIVATEKEY }}
DOCKER_IMAGE_TAG: ${{ needs.sconify.outputs.prod-image-tag }}
CHECKSUM: ${{ needs.sconify.outputs.prod-checksum }}
FINGERPRINT: ${{ needs.sconify.outputs.prod-mrenclave }}
RPC_URL: ${{ secrets.RPC_URL }}
SCONIFY_VERSION: ${{ vars.SCONIFY_VERSION }}
run: |
cd deployment-dapp
npm run deploy-dapp
- name: Push dapp secret
env:
WALLET_PRIVATE_KEY: ${{ secrets.WEB3TELEGRAM_APP_OWNER_PRIVATEKEY }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
RPC_URL: ${{ secrets.RPC_URL }}
run: |
cd deployment-dapp
npm run push-dapp-secret
- name: Publish free sell order
env:
WALLET_PRIVATE_KEY: ${{ secrets.WEB3TELEGRAM_APP_OWNER_PRIVATEKEY }}
PRICE: ${{ vars.SELL_ORDER_PRICE }}
VOLUME: ${{ vars.SELL_ORDER_VOLUME }}
RPC_URL: ${{ secrets.RPC_URL }}
TEE_FRAMEWORK: ${{ vars.TEE_FRAMEWORK }}
run: |
cd deployment-dapp
npm run publish-sell-order
- name: Add resource to whitelist
env:
CONTRACT_ADDRESS: ${{ vars.WEB3TELEGRAM_WHITELIST_CONTRACT_ADDRESS }}
PRIVATE_KEY: ${{ secrets.WEB3TELEGRAM_APP_OWNER_PRIVATEKEY }}
RPC_URL: ${{ secrets.RPC_URL }}
run: |
cd node_modules/whitelist-smart-contract
export ADDRESS_TO_ADD=$(cat ../../deployment-dapp/.app-address)
npm run addResourceToWhitelist -- --network ${{ vars.WHITELIST_NETWORK_NAME }}
- name: Configure ENS
if: ${{ vars.DAPP_ENS_NAME }}
env:
WALLET_PRIVATE_KEY: ${{ secrets.WEB3TELEGRAM_APP_OWNER_PRIVATEKEY }}
DAPP_ENS_NAME: ${{ vars.DAPP_ENS_NAME }}
run: |
cd deployment-dapp
npm run configure-ens