1
- name : Aztec Network EKS Deployment
2
-
3
- # Manual trigerring of this workflow is intentionally disabled
4
- # Helm deployments do not support lock files
5
- # Without a lockfile, manual trigerring can lead to corrupted or partial deployments
1
+ name : Aztec Network Deployment
6
2
7
3
on :
8
- push :
9
- branches :
10
- - staging
11
- - production
12
- pull_request :
13
- branches :
14
- - staging
15
- - production
4
+ workflow_dispatch :
5
+ inputs :
6
+ namespace :
7
+ description : The namespace to deploy to, e.g. smoke
8
+ required : true
9
+ values_file :
10
+ description : The values file to use, e.g. 1-validators.yaml
11
+ required : true
12
+ aztec_docker_image :
13
+ description : The Aztec Docker image to use, e.g. aztecprotocol/aztec:da809c58290f9590836f45ec59376cbf04d3c4ce-x86_64
14
+ required : true
16
15
17
16
jobs :
18
17
network_deployment :
@@ -24,34 +23,67 @@ jobs:
24
23
25
24
# Set up a variable based on the branch name
26
25
env :
27
- NAMESPACE : ${{ github.ref == 'refs/heads/production' && 'production' || 'staging' }}
26
+ AZTEC_DOCKER_IMAGE : ${{ inputs.aztec_docker_image }}
27
+ NAMESPACE : ${{ inputs.namespace }}
28
+ VALUES_FILE : ${{ inputs.values_file }}
28
29
CHART_PATH : ./spartan/aztec-network
30
+ CLUSTER_NAME : aztec-gke
31
+ REGION : us-west1-a
32
+ TF_STATE_BUCKET : aztec-terraform
33
+ GKE_CLUSTER_CONTEXT : gke_testnet-440309_us-west1-a_aztec-gke
29
34
30
35
steps :
31
- # Step 1: Check out the repository's code
32
36
- name : Checkout code
33
37
uses : actions/checkout@v3
34
38
35
- # Step 2: Configure AWS credentials using GitHub Secrets
36
- - name : Configure AWS credentials
37
- uses : aws-actions/configure-aws-credentials@v2
39
+ - name : Authenticate to Google Cloud
40
+ uses : google-github-actions/auth@v2
38
41
with :
39
- aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
40
- aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
41
- aws-region : us-east-1
42
+ credentials_json : ${{ secrets.GCP_SA_KEY }}
43
+
44
+ - name : Set up Cloud SDK
45
+ uses : google-github-actions/setup-gcloud@v2
42
46
43
- # Step 3: Set up Kubernetes context for AWS EKS
44
- - name : Configure kubectl with EKS cluster
47
+ - name : Install GKE Auth Plugin
45
48
run : |
46
- aws eks update-kubeconfig --region us-east-1 --name spartan
49
+ gcloud components install gke-gcloud-auth-plugin --quiet
47
50
48
- # Step 4: Install Helm
49
- - name : Install Helm
51
+ - name : Configure kubectl with GKE cluster
50
52
run : |
51
- curl https://raw.githubusercontent.com/helm/helm/master/scripts/ get-helm-3 | bash
53
+ gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --region ${{ env.REGION }}
52
54
53
- # Step 5: Apply Helm Chart
54
- - name : Deploy Helm chart
55
+ - name : Ensure Terraform state bucket exists
55
56
run : |
56
- helm dependency update ${{ env.CHART_PATH }}
57
- helm upgrade --install ${{ env.NAMESPACE }} ${{ env.CHART_PATH }} --namespace ${{ env.NAMESPACE }} --set network.public=true --atomic --create-namespace --timeout 20m
57
+ if ! gsutil ls gs://${{ env.TF_STATE_BUCKET }} >/dev/null 2>&1; then
58
+ echo "Creating GCS bucket for Terraform state..."
59
+ gsutil mb -l us-east4 gs://${{ env.TF_STATE_BUCKET }}
60
+ gsutil versioning set on gs://${{ env.TF_STATE_BUCKET }}
61
+ else
62
+ echo "Terraform state bucket already exists"
63
+ fi
64
+
65
+ - name : Setup Terraform
66
+ uses : hashicorp/setup-terraform@v2
67
+ with :
68
+ terraform_version : " 1.5.0" # Specify your desired version
69
+
70
+ - name : Terraform Init
71
+ working-directory : ./spartan/terraform/deploy-release
72
+ run : |
73
+ terraform init \
74
+ -backend-config="bucket=${{ env.TF_STATE_BUCKET }}" \
75
+ -backend-config="prefix=network-deploy/${{ env.REGION }}/${{ env.CLUSTER_NAME }}/${{ env.NAMESPACE }}/terraform.tfstate" \
76
+
77
+ - name : Terraform Plan
78
+ working-directory : ./spartan/terraform/deploy-release
79
+ run : |
80
+ terraform plan \
81
+ -var="release_name=${{ env.NAMESPACE }}" \
82
+ -var="values_file=${{ env.VALUES_FILE }}" \
83
+ -var="gke_cluster_context=${{ env.GKE_CLUSTER_CONTEXT }}" \
84
+ -var="aztec_docker_image=${{ env.AZTEC_DOCKER_IMAGE }}" \
85
+ -out=tfplan
86
+
87
+ - name : Terraform Apply
88
+ working-directory : ./spartan/terraform/deploy-release
89
+ run : terraform apply -auto-approve tfplan
0 commit comments