Skip to content

Commit 6689a2f

Browse files
authored
feat: create deploy-rollup-contracts.yml (#16549)
Adds a new GitHub workflow and Terraform configuration for deploying Aztec rollup contracts to Kubernetes clusters. The implementation includes: - A new GitHub workflow file `deploy-rollup-contracts.yml` that can be triggered manually or called from other workflows - Terraform configuration in `spartan/terraform/deploy-rollup-contracts/` to handle the deployment process - Support for both GKE and kind clusters with appropriate backend configurations - Comprehensive configuration options for contract deployment parameters - Extraction and output of deployed contract addresses The workflow allows customization of various Aztec parameters like slot duration, epoch duration, committee size, and other protocol-specific settings. It also supports optional features like sponsored FPC and real verifier deployment.
2 parents c1f1da0 + 79f0f2b commit 6689a2f

File tree

6 files changed

+937
-91
lines changed

6 files changed

+937
-91
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: "Setup K8s and Terraform"
2+
description: "Common setup for Kubernetes cluster access and Terraform initialization"
3+
4+
inputs:
5+
cluster:
6+
description: "The cluster to deploy to (e.g., aztec-gke-private or kind)"
7+
required: true
8+
namespace:
9+
description: "The namespace to deploy to"
10+
required: true
11+
ref:
12+
description: "The branch name to deploy from"
13+
required: false
14+
default: "next"
15+
region:
16+
description: "GCP region"
17+
required: false
18+
default: "us-west1-a"
19+
gcp_sa_key:
20+
description: "GCP service account JSON key"
21+
required: true
22+
kubeconfig_b64:
23+
description: "Base64 encoded kubeconfig for kind clusters"
24+
required: false
25+
terraform_dir:
26+
description: "Terraform working directory"
27+
required: true
28+
tf_state_bucket:
29+
description: "Terraform state bucket for GCS backend"
30+
required: false
31+
default: "aztec-terraform"
32+
tf_state_prefix:
33+
description: "Terraform state prefix for GCS backend"
34+
required: true
35+
additional_state_path:
36+
description: "Additional path component for state (e.g., salt value)"
37+
required: false
38+
default: ""
39+
run_terraform_destroy:
40+
description: "Whether to run terraform destroy"
41+
required: false
42+
default: "false"
43+
44+
outputs:
45+
kubectl_context:
46+
description: "The current kubectl context"
47+
value: ${{ steps.setup_vars.outputs.kubectl_context }}
48+
49+
runs:
50+
using: "composite"
51+
steps:
52+
- name: Check if directory exists
53+
id: check_dir
54+
shell: bash
55+
run: |
56+
if [ -d ".git" ]; then
57+
echo "exists=true" >> $GITHUB_OUTPUT
58+
else
59+
echo "exists=false" >> $GITHUB_OUTPUT
60+
fi
61+
62+
- name: Checkout code
63+
if: ${{ steps.check_dir.outputs.exists != 'true' }}
64+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
65+
with:
66+
ref: ${{ inputs.ref }}
67+
68+
- name: Authenticate to Google Cloud
69+
uses: google-github-actions/auth@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f
70+
with:
71+
credentials_json: ${{ inputs.gcp_sa_key }}
72+
73+
- name: Set up Cloud SDK
74+
uses: google-github-actions/setup-gcloud@6189d56e4096ee891640bb02ac264be376592d6a
75+
76+
- name: Install GKE Auth Plugin
77+
shell: bash
78+
run: |
79+
gcloud components install gke-gcloud-auth-plugin --quiet
80+
81+
- name: Configure kubectl with GKE cluster
82+
if: ${{ inputs.cluster != 'kind' }}
83+
shell: bash
84+
run: |
85+
gcloud container clusters get-credentials ${{ inputs.cluster }} --region ${{ inputs.region }}
86+
87+
- name: Configure kubectl with kind cluster
88+
if: ${{ inputs.cluster == 'kind' }}
89+
shell: bash
90+
run: |
91+
if [ -z "${{ inputs.kubeconfig_b64 }}" ]; then
92+
echo "KUBECONFIG_B64 is not set"
93+
exit 1
94+
fi
95+
mkdir -p $HOME/.kube
96+
echo "${{ inputs.kubeconfig_b64 }}" | base64 -d > $HOME/.kube/config
97+
kubectl config use-context kind-kind
98+
99+
- name: Set up kubectl context
100+
id: setup_vars
101+
shell: bash
102+
run: |
103+
CLUSTER_CONTEXT=$(kubectl config current-context)
104+
echo "kubectl_context=${CLUSTER_CONTEXT}" >> $GITHUB_OUTPUT
105+
echo "TF_VAR_K8S_CLUSTER_CONTEXT=${CLUSTER_CONTEXT}" >> $GITHUB_ENV
106+
107+
- name: Setup Terraform
108+
uses: hashicorp/setup-terraform@v3
109+
with:
110+
terraform_version: "1.5.0"
111+
112+
- name: Terraform Init
113+
shell: bash
114+
working-directory: ${{ inputs.terraform_dir }}
115+
run: |
116+
# Clean up any previous backend overrides
117+
rm -f backend_override.tf
118+
119+
# Build the state path
120+
STATE_PATH="${{ inputs.cluster }}/${{ inputs.namespace }}"
121+
if [ -n "${{ inputs.additional_state_path }}" ]; then
122+
STATE_PATH="${STATE_PATH}/${{ inputs.additional_state_path }}"
123+
fi
124+
125+
if [ "${{ inputs.cluster }}" == "kind" ]; then
126+
# For kind, use local backend
127+
cat > backend_override.tf << EOF
128+
terraform {
129+
backend "local" {
130+
path = "state/${STATE_PATH}/terraform.tfstate"
131+
}
132+
}
133+
EOF
134+
else
135+
# For GKE, use GCS backend
136+
cat > backend_override.tf << EOF
137+
terraform {
138+
backend "gcs" {
139+
bucket = "${{ inputs.tf_state_bucket }}"
140+
prefix = "${{ inputs.tf_state_prefix }}/${{ inputs.region }}/${STATE_PATH}/terraform.tfstate"
141+
}
142+
}
143+
EOF
144+
fi
145+
146+
terraform init -reconfigure
147+
148+
- name: Terraform Destroy
149+
if: ${{ inputs.run_terraform_destroy == 'true' }}
150+
shell: bash
151+
working-directory: ${{ inputs.terraform_dir }}
152+
continue-on-error: true
153+
run: |
154+
terraform destroy -auto-approve

.github/workflows/deploy-eth-devnet.yml

Lines changed: 11 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ jobs:
131131
TF_VAR_RESOURCE_PROFILE: ${{ inputs.resource_profile || 'prod' }}
132132

133133
steps:
134-
- name: debug inputs
134+
- name: Debug inputs
135135
run: |
136136
echo "cluster: ${{ inputs.cluster }}"
137137
echo "namespace: ${{ inputs.namespace }}"
@@ -143,111 +143,31 @@ jobs:
143143
echo "create_static_ips: ${{ inputs.create_static_ips }}"
144144
echo "run_terraform_destroy: ${{ inputs.run_terraform_destroy }}"
145145
146-
- name: Check if directory exists
147-
id: check_dir
148-
run: |
149-
if [ -d ".git" ]; then
150-
echo "exists=true" >> $GITHUB_OUTPUT
151-
else
152-
echo "exists=false" >> $GITHUB_OUTPUT
153-
fi
154-
155-
# if running with `act`, skip the checkout since the code is mounted in
156-
- name: Checkout code
157-
if: ${{ steps.check_dir.outputs.exists != 'true' }}
158-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
146+
- name: Setup K8s and Terraform
147+
uses: ./.github/actions/setup-k8s-terraform
159148
with:
149+
cluster: ${{ inputs.cluster }}
150+
namespace: ${{ inputs.namespace }}
160151
ref: ${{ inputs.ref || github.ref }}
152+
gcp_sa_key: ${{ secrets.GCP_SA_KEY }}
153+
kubeconfig_b64: ${{ secrets.KUBECONFIG_B64 }}
154+
terraform_dir: ./spartan/terraform/deploy-eth-devnet
155+
tf_state_prefix: deploy-eth-devnet
156+
run_terraform_destroy: ${{ inputs.run_terraform_destroy }}
161157

162-
- name: Authenticate to Google Cloud
163-
uses: google-github-actions/auth@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f
164-
with:
165-
credentials_json: ${{ secrets.GCP_SA_KEY }}
166-
167-
- name: Set up Cloud SDK
168-
uses: google-github-actions/setup-gcloud@6189d56e4096ee891640bb02ac264be376592d6a
169-
170-
- name: Install GKE Auth Plugin
171-
run: |
172-
gcloud components install gke-gcloud-auth-plugin --quiet
173-
174-
- name: Configure kubectl with GKE cluster
175-
if: ${{ inputs.cluster != 'kind' }}
176-
run: |
177-
gcloud container clusters get-credentials ${{ inputs.cluster }} --region ${{ env.REGION }}
178-
179-
- name: Configure kubectl with kind cluster
180-
if: ${{ inputs.cluster == 'kind' }}
181-
run: |
182-
# fail if kubeconfig is not provided
183-
if [ -z "${{ secrets.KUBECONFIG_B64 }}" ]; then
184-
echo "KUBECONFIG_B64 is not set"
185-
exit 1
186-
fi
187-
mkdir -p $HOME/.kube
188-
echo "${{ secrets.KUBECONFIG_B64 }}" | base64 -d > $HOME/.kube/config
189-
kubectl config use-context kind-kind
190-
191-
- name: Set up Terraform variables
192-
id: setup_vars
158+
- name: Set up CREATE_STATIC_IPS variable
193159
run: |
194160
# Set CREATE_STATIC_IPS based on cluster type
195-
# Note: Terraform boolean values must be "true" or "false" (lowercase, unquoted)
196161
if [ "${{ inputs.cluster }}" == "kind" ]; then
197162
CREATE_STATIC_IPS=false
198163
else
199-
# Convert string "true"/"false" to boolean for Terraform
200164
if [ "${{ inputs.create_static_ips }}" == "true" ]; then
201165
CREATE_STATIC_IPS=true
202166
else
203167
CREATE_STATIC_IPS=false
204168
fi
205169
fi
206-
207-
# Get kubectl context
208-
CLUSTER_CONTEXT=$(kubectl config current-context)
209-
210-
# Export all as TF_VAR for Terraform
211170
echo "TF_VAR_CREATE_STATIC_IPS=${CREATE_STATIC_IPS}" >> $GITHUB_ENV
212-
echo "TF_VAR_K8S_CLUSTER_CONTEXT=${CLUSTER_CONTEXT}" >> $GITHUB_ENV
213-
214-
- name: Terraform Init
215-
working-directory: ./spartan/terraform/deploy-eth-devnet
216-
run: |
217-
# Clean up any previous backend overrides
218-
rm -f backend_override.tf
219-
220-
if [ "${{ inputs.cluster }}" == "kind" ]; then
221-
# For kind, use local backend with explicit path
222-
cat > backend_override.tf << EOF
223-
terraform {
224-
backend "local" {
225-
path = "state/${{ inputs.cluster }}/${{ inputs.namespace }}/terraform.tfstate"
226-
}
227-
}
228-
EOF
229-
else
230-
# For GKE, use GCS backend with explicit path
231-
cat > backend_override.tf << EOF
232-
terraform {
233-
backend "gcs" {
234-
bucket = "${{ env.TF_STATE_BUCKET }}"
235-
prefix = "deploy-eth-devnet/${{ env.REGION }}/${{ inputs.cluster }}/${{ inputs.namespace }}/terraform.tfstate"
236-
}
237-
}
238-
EOF
239-
fi
240-
241-
terraform init -reconfigure
242-
243-
- name: Terraform Destroy
244-
working-directory: ./spartan/terraform/deploy-eth-devnet
245-
if: ${{ inputs.run_terraform_destroy == 'true' }}
246-
# Destroy fails if the resources are already destroyed, so we continue on error
247-
continue-on-error: true
248-
run: |
249-
# All variables are now set as TF_VAR_ environment variables
250-
terraform destroy -auto-approve
251171
252172
- name: Terraform Plan
253173
working-directory: ./spartan/terraform/deploy-eth-devnet

0 commit comments

Comments
 (0)