forked from zeta-chain/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: CI - Added GH action for basic operations on athens3 validator …
…nodes (zeta-chain#705) * Added action for basic operations on athens3 nodes * Updated workflow name
- Loading branch information
1 parent
33130b2
commit 486d150
Showing
3 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/bash | ||
|
||
function set_regions() { | ||
export regions=( | ||
"us-east-1" | ||
"us-west-2" | ||
"eu-west-1" | ||
"ap-southeast-1" | ||
) | ||
} | ||
|
||
function stop_zetavisor() { | ||
COMMAND_ID=$(aws ssm send-command \ | ||
--targets Key=tag:configured-by,Values=ansible \ | ||
--document-name "AWS-RunShellScript" \ | ||
--parameters 'commands=["systemctl stop zetavisor"]' \ | ||
--region "$1" | jq .Command.CommandId -r || exit 1) | ||
echo "$COMMAND_ID" | ||
} | ||
|
||
function stop_zetaclient() { | ||
COMMAND_ID=$(aws ssm send-command \ | ||
--targets Key=tag:Role,Values=validator \ | ||
--document-name "AWS-RunShellScript" \ | ||
--parameters 'commands=["systemctl stop zetaclientd"]' \ | ||
--region "$1" | jq .Command.CommandId -r || exit 1) | ||
echo "$COMMAND_ID" | ||
} | ||
|
||
function restart_zetavisor() { | ||
COMMAND_ID=$(aws ssm send-command \ | ||
--targets Key=tag:configured-by,Values=ansible \ | ||
--document-name "AWS-RunShellScript" \ | ||
--parameters 'commands=["systemctl restart zetavisor"]' \ | ||
--region "$1" | jq .Command.CommandId -r || exit 1) | ||
echo "$COMMAND_ID" | ||
} | ||
|
||
function restart_zetaclient() { | ||
COMMAND_ID=$(aws ssm send-command \ | ||
--targets Key=tag:Role,Values=validator \ | ||
--document-name "AWS-RunShellScript" \ | ||
--parameters 'commands=["systemctl restart zetaclientd"]' \ | ||
--region "$1" | jq .Command.CommandId -r || exit 1) | ||
echo "$COMMAND_ID" | ||
} | ||
|
||
function delete_zetaclient_db() { | ||
COMMAND_ID=$(aws ssm send-command \ | ||
--targets Key=tag:Role,Values=validator \ | ||
--document-name "AWS-RunShellScript" \ | ||
--parameters 'commands=["rm -rf /home/zetachain/.zetaclient/*"]' \ | ||
--region "$1" | jq .Command.CommandId -r || exit 1) | ||
echo "$COMMAND_ID" | ||
} | ||
|
||
function unjail_validators() { | ||
COMMAND_ID=$(aws ssm send-command \ | ||
--targets Key=tag:Role,Values=validator \ | ||
--document-name "AWS-RunShellScript" \ | ||
--parameters "commands=['export HOME=/home/zetachain && zetacored tx slashing unjail --chain-id athens_7001-1 --from operator -y']" \ | ||
--region "$1" | jq .Command.CommandId -r || exit 1) | ||
echo "$COMMAND_ID" | ||
} | ||
|
||
check_cmd_status() { | ||
COMMAND_ID=$1 | ||
echo "COMMAND_ID: $COMMAND_ID" | ||
COMMAND_STATUS=$(aws ssm list-commands --command-id "$COMMAND_ID" | jq '.Commands[0].Status' -r) | ||
until [[ "$COMMAND_STATUS" == "Success" || "$COMMAND_STATUS" == "Failed" ]]; do | ||
echo "Waiting for Command to complete. ID: $COMMAND_ID | Status: $COMMAND_STATUS" | ||
sleep 2 | ||
COMMAND_STATUS=$(aws ssm list-commands --command-id "$COMMAND_ID" | jq '.Commands[0].Status' -r) | ||
done | ||
echo "Complete. ID: $COMMAND_ID | Status: $COMMAND_STATUS" | ||
if [ "$COMMAND_STATUS" == "Failed" ]; then | ||
echo "Command ID $COMMAND_ID Failed" && exit 1 | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
name: Node Operations - Athens 3 | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
ZETACORED_STATUS: | ||
description: "Do you want to stop, or restart zetacored?" | ||
type: choice | ||
options: | ||
- "stop" | ||
- "restart" | ||
required: true | ||
ZETACLIENTD_STATUS: | ||
description: "Do you want to stop, or restart zetaclientd?" | ||
type: choice | ||
options: | ||
- "stop" | ||
- "restart" | ||
required: true | ||
DELETE_ZETACLIENT_DB: | ||
description: "Which environment to update?" | ||
type: environment | ||
required: true | ||
# ENVIRONMENT: | ||
# description: "Which environment to update?" | ||
# type: environment | ||
# required: true | ||
|
||
env: | ||
AWS_REGION: "us-east-1" | ||
|
||
jobs: | ||
start-stop-processes: | ||
runs-on: ubuntu-latest | ||
# environment: ${{ github.event.inputs.ENVIRONMENT }} | ||
environment: athens3-validators | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install Pipeline Dependencies | ||
uses: ./.github/actions/install-dependencies | ||
with: | ||
skip_python: "true" | ||
skip_docker_compose: "true" | ||
skip_go: "true" | ||
# cpu_architecture: "arm64" | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Stop zetacored | ||
if: ${{ github.event.inputs.ZETACORED_STATUS == 'stop' }} | ||
run: | | ||
source .github/actions/node-operations/functions | ||
set_regions | ||
for region in "${regions[@]}"; do | ||
stop_zetavisor "$region" | ||
done | ||
- name: Restart zetacored | ||
if: ${{ github.event.inputs.ZETACORED_STATUS == 'restart' }} | ||
run: | | ||
source .github/actions/node-operations/functions | ||
set_regions | ||
for region in "${regions[@]}"; do | ||
restart_zetavisor "$region" | ||
done | ||
- name: Stop zetaclientd | ||
if: ${{ github.event.inputs.ZETACORED_STATUS == 'stop' }} | ||
run: | | ||
source .github/actions/node-operations/functions | ||
set_regions | ||
for region in "${regions[@]}"; do | ||
stop_zetaclient "$region" | ||
done | ||
- name: Delete zetaclientd db (/home/zetachain/.zetaclient/*) | ||
if: ${{ github.event.inputs.DELETE_ZETACLIENT_DB == 'true' }} | ||
run: | | ||
source .github/actions/node-operations/functions | ||
set_regions | ||
for region in "${regions[@]}"; do | ||
echo "Deleting zetaclient db in $region" | ||
delete_zetaclient_db "$region" | ||
done | ||
- name: Restart zetaclientd | ||
if: ${{ github.event.inputs.ZETACORED_STATUS == 'restart' }} | ||
run: | | ||
source .github/actions/node-operations/functions | ||
set_regions | ||
for region in "${regions[@]}"; do | ||
restart_zetaclient "$region" | ||
done |