Skip to content

Commit

Permalink
call the check deploy scripts with params
Browse files Browse the repository at this point in the history
  • Loading branch information
yourmoonlight committed Oct 28, 2023
1 parent 6a2e15f commit 5570631
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 42 deletions.
43 changes: 1 addition & 42 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,45 +50,4 @@ jobs:
echo "$PRIVATE_KEY" > private_key.pem
chmod 600 private_key.pem
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST bash -c "'sleep 30' && docker ps | grep rooch | awk '{print \$1}' | xargs -r docker stop && docker ps -a | grep rooch | awk '{print \$1}' | xargs -r docker rm -f && docker pull 'ghcr.io/rooch-network/rooch:${{ steps.docker_meta.outputs.version }}' && docker run -d -v /root:/root -p 50051:50051 'ghcr.io/rooch-network/rooch:${{ steps.docker_meta.outputs.version }}' server start -n dev --eth-rpc-url https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST $'
KEYWORD="rooch"
IMAGE_TAG=${{ steps.docker_meta.outputs.version }}
DEV_MNEMONIC_PHRASE=${{ secrets.DEV_MNEMONIC_PHRASE }}
# get the container id
CONTAINER_ID=$(docker ps -a | grep $KEYWORD | awk \'{print $1}\')
if [ -z "$CONTAINER_ID" ]; then
echo "No container found related to the keyword $KEYWORD"
exit 1
fi
sleep 30
# get container status
STATUS=$(docker inspect --format "{{.State.Status}}" $CONTAINER_ID)
if [ "$STATUS" != "running" ]; then
echo "Container $CONTAINER_ID is not running, trying to clean data and restart"
echo "Start cleaning the data with image_tag: $IMAGE_TAG"
docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch:$IMAGE_TAG server clean -n dev
rm -rf ~/.rooch
docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch:$IMAGE_TAG init -m "$(echo $DEV_MNEMONIC_PHRASE)" --skip-password
docker start $CONTAINER_ID
if [ $? -eq 0 ]; then
echo "Container $CONTAINER_ID Successfully restarted."
echo "Redeploy the examples"
for dir in /root/rooch/examples/*/; do
dir=${dir%*/}
name_addr=$(basename $dir)
echo $name_addr
docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch:$IMAGE_TAG move build -p "$dir" --named-addresses rooch_examples=default,$name_addr=default
docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch:$IMAGE_TAG move publish -p "$dir" --named-addresses rooch_examples=default,$name_addr=default
done
else
echo "Container $CONTAINER_ID Startup failed, please check the reason."
fi
else
echo "Container $CONTAINER_ID is running"
fi
'
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST "cd /root/rooch && git pull origin main && bash scripts/check_dev_deploy_status.sh ${{ steps.docker_meta.outputs.version }} ${{ secrets.DEV_MNEMONIC_PHRASE }}"
49 changes: 49 additions & 0 deletions scripts/check_dev_deploy_status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
# Copyright (c) RoochNetwork
# SPDX-License-Identifier: Apache-2.0

if [ "$#" -lt 2 ]; then
echo "Usage: $0 <param1> [param2 ...]"
exit 1
fi

KEYWORD="rooch"
IMAGE_TAG="$1"
DEV_MNEMONIC_PHRASE="$2"

# get the container id
CONTAINER_ID=$(docker ps -a | grep $KEYWORD | awk \'{print $1}\')

if [ -z "$CONTAINER_ID" ]; then
echo "No container found related to the keyword $KEYWORD"
exit 1
fi

sleep 30

# get container status
STATUS=$(docker inspect --format "{{.State.Status}}" $CONTAINER_ID)

if [ "$STATUS" != "running" ]; then
echo "Container $CONTAINER_ID is not running, trying to clean data and restart"
echo "Start cleaning the data with image_tag: $IMAGE_TAG"
docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch:$IMAGE_TAG server clean -n dev
rm -rf ~/.rooch
docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch:$IMAGE_TAG init -m "$(echo $DEV_MNEMONIC_PHRASE)" --skip-password
docker start $CONTAINER_ID
if [ $? -eq 0 ]; then
echo "Container $CONTAINER_ID Successfully restarted."
echo "Redeploy the examples"
for dir in /root/rooch/examples/*/; do
dir=${dir%*/}
name_addr=$(basename $dir)
echo $name_addr
docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch:$IMAGE_TAG move build -p "$dir" --named-addresses rooch_examples=default,$name_addr=default
docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch:$IMAGE_TAG move publish -p "$dir" --named-addresses rooch_examples=default,$name_addr=default
done
else
echo "Container $CONTAINER_ID Startup failed, please check the reason."
fi
else
echo "Container $CONTAINER_ID is running"
fi

0 comments on commit 5570631

Please sign in to comment.