diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index ed2a86a790..3697b927d4 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -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: @@ -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" \ No newline at end of file + 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 }}" \ No newline at end of file diff --git a/scripts/check_dev_deploy_status.sh b/scripts/check_dev_deploy_status.sh index d2c9bd4042..a05fa608ce 100644 --- a/scripts/check_dev_deploy_status.sh +++ b/scripts/check_dev_deploy_status.sh @@ -2,7 +2,14 @@ # Copyright (c) RoochNetwork # SPDX-License-Identifier: Apache-2.0 +if [ "$#" -lt 2 ]; then + echo "Usage: $0 [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}') @@ -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 running,trying 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." @@ -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."