Skip to content

Commit

Permalink
feat(ci): split deploy scripts for testnet and mainnet
Browse files Browse the repository at this point in the history
Refactor deployment workflows for distinct environments. Added separate scripts for testnet and mainnet deployments. Introduced a new constant for default max retry times in DAServerOpenDAActor.
  • Loading branch information
popcnt1 committed Sep 19, 2024
1 parent de143eb commit 00b215e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/deploy_mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,11 @@ jobs:
chmod 600 private_key.pem
sudo apt update
sudo apt install -y --no-install-recommends openssh-server
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST bash -c "'sleep 30' && && docker image prune -a -f && 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:${{ github.event.inputs.tagName }}' && docker run -d -v /data:/root -p 6767:6767 'ghcr.io/rooch-network/rooch:${{ github.event.inputs.tagName }}' server start -n main --btc-rpc-url '${{secrets.BTC_MAIN_RPC_URL}}' --btc-rpc-username rooch-main --btc-rpc-password '${{secrets.BTC_MAIN_RPC_PWD}}'"
BRANCH=$(basename ${{ github.ref }})
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST \
"cd /root/rooch && git fetch origin && git checkout -B $BRANCH origin/$BRANCH || git checkout $BRANCH && bash scripts/deploy_rooch_testnet.sh \
'${{ env.REF }}' \
'${{ secrets.BTC_MAIN_RPC_URL }}' \
'${{ secrets.BTC_MAIN_RPC_PWD }}' \
'${{ secrets.OPENDA_GCP_MAINNET_BUCKET }}' \
'${{ secrets.OPENDA_GCP_MAINNET_CREDENTIAL }}'"
2 changes: 1 addition & 1 deletion .github/workflows/deploy_testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
sudo apt install -y --no-install-recommends openssh-server
BRANCH=$(basename ${{ github.ref }})
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST \
"cd /root/rooch && git fetch origin && git checkout -B $BRANCH origin/$BRANCH || git checkout $BRANCH && bash scripts/deploy_rooch.sh \
"cd /root/rooch && git fetch origin && git checkout -B $BRANCH origin/$BRANCH || git checkout $BRANCH && bash scripts/deploy_rooch_testnet.sh \
'${{ env.REF }}' \
'${{ secrets.BTC_TEST_RPC_URL }}' \
'${{ secrets.BTC_TEST_RPC_PWD }}' \
Expand Down
3 changes: 2 additions & 1 deletion crates/rooch-da/src/server/openda/actor/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct DAServerOpenDAActor {
}

pub const DEFAULT_MAX_SEGMENT_SIZE: u64 = 4 * 1024 * 1024;
pub const DEFAULT_MAX_RETRY_TIMES: usize = 4;

impl Actor for DAServerOpenDAActor {}

Expand Down Expand Up @@ -166,7 +167,7 @@ async fn new_retry_operator(
max_retry_times: Option<usize>,
) -> Result<Operator> {
let mut op = Operator::via_map(scheme, config)?;
let max_times = max_retry_times.unwrap_or(4);
let max_times = max_retry_times.unwrap_or(DEFAULT_MAX_RETRY_TIMES);
op = op
.layer(RetryLayer::new().with_max_times(max_times))
.layer(LoggingLayer::default());
Expand Down
21 changes: 21 additions & 0 deletions scripts/deploy_rooch_mainnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# Copyright (c) RoochNetwork
# SPDX-License-Identifier: Apache-2.0

REF="$1"
BTC_MAIN_RPC_URL="$2"
BTC_MAIN_RPC_PWD="$3"
OPENDA_GCP_MAINNET_BUCKET="$4"
OPENDA_GCP_MAINNET_CREDENTIAL="$5"

sleep 30
docker image prune -a -f
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:$REF"
docker run -d --name rooch --restart unless-stopped -v /data:/root -p 6767:6767 -p 9184:9184 -e RUST_BACKTRACE=full "ghcr.io/rooch-network/rooch:$REF" \
server start -n main \
--btc-rpc-url "$BTC_MAIN_RPC_URL" \
--btc-rpc-username rooch-main \
--btc-rpc-password "$BTC_MAIN_RPC_PWD" \
--da "{\"internal-da-server\": {\"servers\": [{\"open-da\": {\"scheme\": \"gcs\", \"config\": {\"bucket\": \"$OPENDA_GCP_MAINNET_BUCKET\", \"credential\": \"$OPENDA_GCP_MAINNET_CREDENTIAL\"}}}]}}"
File renamed without changes.

0 comments on commit 00b215e

Please sign in to comment.