-
Notifications
You must be signed in to change notification settings - Fork 594
239 lines (224 loc) · 8.5 KB
/
deploy-eth-devnet.yml
File metadata and controls
239 lines (224 loc) · 8.5 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
name: Deploy Eth Devnet
# This workflow is used to deploy the eth devnet to a cluster.
# It can be used to deploy to kind or a GKE cluster.
#
# Set yourself up to run locally with:
# export GOOGLE_APPLICATION_CREDENTIALS=/your/path/to/testnet-helm-sa.json
# alias lwfl=/your/path/to/aztec-clones/alpha/.github/local_workflow.sh
#
# Then deploy to kind:
# lwfl deploy_eth_devnet --input cluster=kind --input resource_profile=dev --input namespace=mitch-eth-devnet --input create_static_ips=false
#
# Or to a GKE cluster:
# lwfl deploy_eth_devnet --input cluster=aztec-gke-private --input resource_profile=prod --input namespace=mitch-eth-devnet --input create_static_ips=false
on:
workflow_call:
inputs:
cluster:
description: The cluster to deploy to, e.g. aztec-gke-private or kind
required: true
type: string
namespace:
description: The namespace to deploy to
required: true
type: string
ref:
description: The branch name to deploy from
required: true
type: string
chain_id:
description: Ethereum chain ID for genesis generation
required: false
type: number
default: 1337
block_time:
description: Block time in seconds for genesis generation
required: false
type: number
default: 12
gas_limit:
description: Gas limit for blocks in genesis generation
required: false
type: string
default: "32000000"
resource_profile:
description: Resource profile to use (dev or prod)
required: true
type: string
create_static_ips:
description: Whether to create static IPs as part of the eth devnet for the execution and beacon nodes
required: true
type: string
run_terraform_destroy:
description: Whether to run the terraform destroy
required: false
type: string
default: "false"
mnemonic:
description: The mnemonic to use for the eth devnet
required: false
type: string
default: "test test test test test test test test test test test junk"
prefunded_mnemonic_indices:
description: The indices of the prefunded mnemonic to use for the devnet
required: false
type: string
default: "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1000,1001,1002,1003"
secrets:
GCP_SA_KEY:
description: The JSON key for the GCP service account
required: true
KUBECONFIG_B64:
description: The base64 encoded kubeconfig
required: true
outputs:
rpc_url:
description: The RPC URL for the eth devnet
value: ${{ jobs.deploy_eth_devnet.outputs.rpc_url }}
ws_url:
description: The WebSocket URL for the eth devnet
value: ${{ jobs.deploy_eth_devnet.outputs.ws_url }}
beacon_url:
description: The Beacon URL for the eth devnet
value: ${{ jobs.deploy_eth_devnet.outputs.beacon_url }}
chain_id:
description: The chain ID for the eth devnet
value: ${{ jobs.deploy_eth_devnet.outputs.chain_id }}
workflow_dispatch:
inputs:
cluster:
description: The cluster to deploy to, e.g. aztec-gke-private or kind
required: true
type: string
namespace:
description: The namespace to deploy to
required: true
type: string
ref:
description: The branch name to deploy from.
required: true
type: string
chain_id:
description: Ethereum chain ID for genesis generation
required: false
type: number
default: 1337
block_time:
description: Block time in seconds for genesis generation
required: false
type: number
default: 12
gas_limit:
description: Gas limit for blocks in genesis generation
required: false
type: string
default: "32000000"
resource_profile:
description: Resource profile to use (dev or prod)
required: true
type: string
create_static_ips:
description: Whether to create static IPs as part of the eth devnet for the execution and beacon nodes
required: true
type: string
run_terraform_destroy:
description: Whether to run the terraform destroy
required: false
type: string
default: "false"
mnemonic:
description: The mnemonic to use for the eth devnet
required: false
type: string
default: "test test test test test test test test test test test junk"
prefunded_mnemonic_indices:
description: The indices of the prefunded mnemonic to use for the devnet
required: false
type: string
default: "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1000,1001,1002,1003"
jobs:
deploy_eth_devnet:
runs-on: ubuntu-latest
outputs:
rpc_url: ${{ steps.get-eth-devnet-results.outputs.rpc_url }}
ws_url: ${{ steps.get-eth-devnet-results.outputs.ws_url }}
beacon_url: ${{ steps.get-eth-devnet-results.outputs.beacon_url }}
chain_id: ${{ steps.get-eth-devnet-results.outputs.chain_id }}
env:
TF_STATE_BUCKET: aztec-terraform
REGION: us-west1-a
# Common Terraform variables as environment variables
TF_VAR_NAMESPACE: ${{ inputs.namespace }}
TF_VAR_CHAIN_ID: ${{ inputs.chain_id }}
TF_VAR_BLOCK_TIME: ${{ inputs.block_time }}
TF_VAR_GAS_LIMIT: ${{ inputs.gas_limit }}
TF_VAR_PREFUNDED_MNEMONIC_INDICES: ${{ inputs.prefunded_mnemonic_indices }}
TF_VAR_RESOURCE_PROFILE: ${{ inputs.resource_profile }}
steps:
- name: Mask the mnemonic
id: mask-mnemonic
run: |
echo "::add-mask::${{ inputs.mnemonic }}"
- name: Debug inputs
run: |
echo "cluster: ${{ inputs.cluster }}"
echo "namespace: ${{ inputs.namespace }}"
echo "ref: ${{ inputs.ref }}"
echo "chain_id: ${{ inputs.chain_id }}"
echo "block_time: ${{ inputs.block_time }}"
echo "gas_limit: ${{ inputs.gas_limit }}"
echo "resource_profile: ${{ inputs.resource_profile }}"
echo "create_static_ips: ${{ inputs.create_static_ips }}"
echo "run_terraform_destroy: ${{ inputs.run_terraform_destroy }}"
- name: Setup K8s and Terraform
uses: ./.github/actions/setup-k8s-terraform
with:
cluster: ${{ inputs.cluster }}
namespace: ${{ inputs.namespace }}
ref: ${{ inputs.ref || github.ref }}
gcp_sa_key: ${{ secrets.GCP_SA_KEY }}
kubeconfig_b64: ${{ secrets.KUBECONFIG_B64 }}
terraform_dir: ./spartan/terraform/deploy-eth-devnet
tf_state_prefix: deploy-eth-devnet
run_terraform_destroy: ${{ inputs.run_terraform_destroy }}
- name: Set up CREATE_STATIC_IPS variable
run: |
# Set CREATE_STATIC_IPS based on cluster type
if [ "${{ inputs.cluster }}" == "kind" ]; then
CREATE_STATIC_IPS=false
else
if [ "${{ inputs.create_static_ips }}" == "true" ]; then
CREATE_STATIC_IPS=true
else
CREATE_STATIC_IPS=false
fi
fi
echo "TF_VAR_CREATE_STATIC_IPS=${CREATE_STATIC_IPS}" >> $GITHUB_ENV
- name: Terraform Plan
working-directory: ./spartan/terraform/deploy-eth-devnet
run: |
# All variables are now set as TF_VAR_ environment variables
terraform plan -out=tfplan
- name: Terraform Apply
working-directory: ./spartan/terraform/deploy-eth-devnet
run: |
terraform apply tfplan
- name: Get eth devnet deployment results
id: get-eth-devnet-results
working-directory: ./spartan/terraform/deploy-eth-devnet
run: |
echo "=== Eth Devnet Deployment Results ==="
# Get outputs from the eth-devnet deployment
RPC_URL=$(terraform output -raw eth_execution_rpc_url)
WS_URL=$(terraform output -raw eth_execution_ws_url)
BEACON_URL=$(terraform output -raw eth_beacon_api_url)
CHAIN_ID=$(terraform output -raw chain_id)
echo "RPC_URL: $RPC_URL"
echo "WS_URL: $WS_URL"
echo "BEACON_URL: $BEACON_URL"
echo "CHAIN_ID: $CHAIN_ID"
# Export as outputs for other steps
echo "rpc_url=$RPC_URL" >> $GITHUB_OUTPUT
echo "ws_url=$WS_URL" >> $GITHUB_OUTPUT
echo "beacon_url=$BEACON_URL" >> $GITHUB_OUTPUT
echo "chain_id=$CHAIN_ID" >> $GITHUB_OUTPUT