Skip to content

Deploy TESTNET Seed #102

Deploy TESTNET Seed

Deploy TESTNET Seed #102

name: Deploy TESTNET Seed
on:
release:
types: [published, prereleased, released]
workflow_dispatch:
inputs:
ref:
description: 'Tag or branch to deploy'
required: true
default: 'refs/tags/v0.0.0'
event_name:
description: 'Event name (use "release" to simulate release event)'
required: true
default: 'workflow_dispatch'
action:
description: 'Action name (e.g., "published", "prereleased", "released")'
required: false
default: ''
jobs:
deploy-rooch-testnet:
name: Deploy Rooch Testnet
runs-on: self-hosted
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'prereleased' || github.event.action == 'released')) ||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Determine ref
id: determine-ref
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "REF=${{ github.event.inputs.ref }}" >> $GITHUB_ENV
echo "EVENT_NAME=${{ github.event.inputs.event_name }}" >> $GITHUB_ENV
echo "ACTION=${{ github.event.inputs.action }}" >> $GITHUB_ENV
else
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
REF=${GITHUB_REF#refs/tags/}
elif [[ "${{ github.ref }}" == refs/heads/* ]]; then
REF=${GITHUB_REF#refs/heads/}
fi
echo "REF=$REF" >> $GITHUB_ENV
echo "EVENT_NAME=${{ github.event_name }}" >> $GITHUB_ENV
echo "ACTION=${{ github.event.action }}" >> $GITHUB_ENV
fi
- name: Print ref and event info
run: |
echo "The ref is ${{ env.REF }}"
echo "The event name is ${{ env.EVENT_NAME }}"
echo "The action is ${{ env.ACTION }}"
- name: Deploy to GCP TESTNET VM
if: |
env.EVENT_NAME == 'workflow_dispatch' ||
(env.EVENT_NAME == 'release' && (env.ACTION == 'published' || env.ACTION == 'prereleased' || env.ACTION == 'released')) ||
(env.EVENT_NAME == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
env:
PRIVATE_KEY: ${{ secrets.GCP_TEST_WORKFLOW_PK }}
HOST: ${{ secrets.GCP_TEST_WORKFLOW_VM }}
USER: ${{ secrets.GCP_TESTNET_VM_USER }}
run: |
echo "$PRIVATE_KEY" > private_key.pem
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:${{ env.REF }}' && docker run -d --name rooch --restart unless-stopped -v /root:/root -p 50051:50051 'ghcr.io/rooch-network/rooch:${{ env.REF }}' server start -n test --btc-rpc-url '${{secrets.BTC_TEST_RPC_URL}}' --btc-rpc-username rooch-test --btc-rpc-password '${{secrets.BTC_TEST_RPC_PWD}}' --da '{\"internal-da-server\": {\"servers\": [{\"open-da\": {\"scheme\": \"gcs\", \"config\": {\"bucket\": \"${{secrets.OPENDA_GCP_TESTNET_BUCKET}}\", \"credential\": \"${{secrets.OPENDA_GCP_TESTNET_CREDENTIAL}}\"}}}]}}'"