Skip to content

Commit

Permalink
♻️ add workflows for deploying full node and validator (#10)
Browse files Browse the repository at this point in the history
* ♻️ add workflows for deploying full node and validator with version control

* 🔧 add `clean_db` option to deployment workflows
  • Loading branch information
yezz123 authored Feb 5, 2025
1 parent b7b9f14 commit 6bf6d0d
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/deploy-fullnode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Deploy Full Node

on:
workflow_dispatch:
inputs:
version:
description: 'Version tag or commit hash'
required: true
clean_db:
description: 'Clean validator DB'
type: boolean
default: false

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/[email protected]
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}

- name: Setup GCloud
uses: google-github-actions/setup-gcloud@v2

- name: Deploy
run: |
gcloud compute ssh --zone "${{ secrets.GCP_ZONE }}" "${{ secrets.FULLNODE_NAME }}" \
--tunnel-through-iap \
--project "${{ secrets.GCP_PROJECT }}" \
--command "sudo /home/pui/scripts/update/update_fullnode.sh ${{ github.event.inputs.version }} ${{ github.event.inputs.clean_db }}"
30 changes: 30 additions & 0 deletions .github/workflows/deploy-validator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Deploy Validator

on:
workflow_dispatch:
inputs:
version:
description: 'Version tag or commit hash'
required: true
clean_db:
description: 'Clean validator DB'
type: boolean
default: false

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/[email protected]
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}

- name: Setup GCloud
uses: google-github-actions/setup-gcloud@v2

- name: Deploy
run: |
gcloud compute ssh --zone "${{ secrets.GCP_ZONE }}" "${{ secrets.VALIDATOR_NAME }}" \
--tunnel-through-iap \
--project "${{ secrets.GCP_PROJECT }}" \
--command "sudo /home/pui/scripts/update/update_validator.sh ${{ github.event.inputs.version }} ${{ github.event.inputs.clean_db }}"
5 changes: 3 additions & 2 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
name: Workflow - Pull Request

on:
workflow_dispatch:
pull_request:
branches: [main]

paths-ignore:
- 'scripts/**'
- '.github/**'

concurrency:
group: pr-checks-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
25 changes: 25 additions & 0 deletions scripts/update/update_fullnode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -e

VERSION=$1
CLEAN_DB=$2

# Access the Home directory where we have the PUI Folder
cd /home/pui

# Update the PUI Node
sudo git fetch
sudo git checkout $VERSION

# Build the PUI Node
sudo cargo build --release --bin sui-node

# Stop the PUI Node
sudo systemctl stop sui-node

if [ "$CLEAN_DB" = "true" ]; then
sudo rm -rf /home/sui-db/
fi

# Start the PUI Node
sudo systemctl start sui-node
28 changes: 28 additions & 0 deletions scripts/update/update_validator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
set -e

VERSION=$1
CLEAN_DB=$2

# Access the Home directory where we have the PUI Folder
cd /home/pui

# Update the PUI Node
sudo git fetch
sudo git checkout $VERSION

# Build the PUI Node
sudo cargo build --release --bin sui-node

# Stop the PUI Node
sudo systemctl stop sui-node

if [ "$CLEAN_DB" = "true" ]; then
sudo rm -rf /opt/sui/db/authorities_db /opt/sui/db/consensus_db
fi

# Copy the new binary to the target directory
sudo mv ./target/release/sui-node /opt/sui/bin/

# Start the PUI Node
sudo systemctl start sui-node

0 comments on commit 6bf6d0d

Please sign in to comment.