-
Notifications
You must be signed in to change notification settings - Fork 18
70 lines (67 loc) · 2.66 KB
/
deploy_gcp_bootnodes.yaml
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
name: Deploy GCP Testnet Bootnodes
on:
push:
tags:
- 'v*' # This will match any tag that starts with 'v'
permissions:
id-token: write
contents: read
jobs:
build-and-release:
runs-on: ubuntu-latest
environment:
name: "test" #will expand to other envs later, currently "test" deploys to the 5 GCP bootnodes
outputs:
environment: ${{ steps.set-env.outputs.environment }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Set Version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Build Binary
run: |
make build
- id: auth
uses: google-github-actions/auth@v2
with:
workload_identity_provider: projects/784882329213/locations/global/workloadIdentityPools/github-oidc-pool/providers/github-oidc-provider
service_account: [email protected]
- name: Install Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
version: 'latest'
project_id: ${{ vars.GCP_PROJECT_ID }}
- name: Upload Binary and config for contracts npm modules to GCP
run: |
BINARY_NAME=${GITHUB_REF#refs/tags/}
gsutil cp ./bin/masa-node gs://${{ vars.GCP_BUCKET_NAME }}/$BINARY_NAME/masa-node
gsutil cp ./bin/masa-node gs://${{ vars.GCP_BUCKET_NAME }}/masa-node
gsutil cp ./contracts/* gs://${{ vars.GCP_BUCKET_NAME }}/$BINARY_NAME/
gsutil cp ./contracts/* gs://${{ vars.GCP_BUCKET_NAME }}/
deploy:
needs: build-and-release
runs-on: ubuntu-latest
environment:
name: test
steps:
- id: auth
uses: google-github-actions/auth@v2
with:
workload_identity_provider: projects/784882329213/locations/global/workloadIdentityPools/github-oidc-pool/providers/github-oidc-provider
service_account: [email protected]
- name: Update Instance Metadata
run: |
ENVIRONMENT="test"
echo "Looking for instances with env metadata: $ENVIRONMENT"
INSTANCES=$(gcloud compute instances list --filter="metadata.items.ENV=$ENVIRONMENT" --format="get(name)")
echo "Found instances: $INSTANCES"
for INSTANCE in $INSTANCES; do
ZONE=$(gcloud compute instances list --filter="name=($INSTANCE)" --format="get(zone)" --limit=1)
echo "Updating instance: $INSTANCE in zone: $ZONE"
gcloud compute instances add-metadata $INSTANCE --metadata masa-oracle-redeploy=${GITHUB_REF#refs/tags/} --zone=$(echo $ZONE | tr -d '\n')
done