Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ci deploy #1060

Merged
merged 5 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,10 @@ jobs:
# images: rooch/rooch,ghcr.io/rooch-network/rooch
images: ghcr.io/rooch-network/rooch
tag-sha: true # add git short SHA as Docker tag
# -
# name: Set up QEMU
# uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver: docker
# - name: Login to DockerHub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
Expand All @@ -54,10 +46,8 @@ jobs:
PRIVATE_KEY: ${{ secrets.GCP_SSH_PRIVATE_KEY }}
HOST: ${{ secrets.GCP_VM_HOST }}
USER: ${{ secrets.GCP_VM_USER }}
DEV_MNEMONIC_PHRASE: ${{secrets.DEV_MNEMONIC_PHRASE}}
IMAGE_TAG: ${{ steps.docker_meta.outputs.version }}
run: |
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 "cd /root/rooch && git pull origin main && bash scripts/check_dev_deploy_status.sh"
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 }}"
23 changes: 16 additions & 7 deletions scripts/check_dev_deploy_status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
# 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}')
Expand All @@ -12,15 +19,17 @@ if [ -z "$CONTAINER_ID" ]; then
exit 1
fi

sleep 30

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

if [ "$STATUS" != "running" ]; then
echo "Container $CONTAINER_ID is not runningtrying to clean data and restart"
echo "Start cleaning the data."
docker run --rm -v /root:/root ghcr.io/rooch-network/rooch:$(echo $IMAGE_TAG) server clean -n dev
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:$(echo $IMAGE_TAG) init -m "$(echo $DEV_MNEMONIC_PHRASE)" --skip-password
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."
Expand All @@ -29,8 +38,8 @@ if [ "$STATUS" != "running" ]; then
dir=${dir%*/}
name_addr=$(basename $dir)
echo $name_addr
docker run --rm -v /root:/root ghcr.io/rooch-network/rooch:$(echo $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:$(echo $IMAGE_TAG) move publish -p "$dir" --named-addresses rooch_examples=default,$name_addr=default
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."
Expand Down
Loading