Skip to content

Commit

Permalink
only deploy rooch container && use artifact to pass image tag between…
Browse files Browse the repository at this point in the history
… workflow (#1823)
  • Loading branch information
yourmoonlight authored Jun 5, 2024
1 parent d052c28 commit 3b7f9dd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
31 changes: 21 additions & 10 deletions .github/workflows/deploy_testnet.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Deploy TESTNET Seed

on:
release:
types: [released, prereleased]
workflow_dispatch:
inputs:
ref:
Expand All @@ -20,27 +19,40 @@ jobs:
github.event_name == 'workflow_dispatch' ||
(github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'release' &&
(github.event.release.prerelease == true || github.event.release.prerelease == false))
(github.event.release.prerelease == true || github.event.release.prerelease == false)) ||
github.event_name == 'workflow_run'
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Download Docker tag artifact
if: github.event_name == 'workflow_run'
uses: actions/download-artifact@v2
with:
name: docker_tag
path: .

- name: Determine ref
id: determine-ref
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "REF=${{ github.event.inputs.ref }}" >> $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/}
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
echo "REF=$(cat docker_tag.txt)" >> $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
fi
echo "REF=$REF" >> $GITHUB_ENV
fi
- name: Print ref
run: echo "The ref is ${{ env.REF }}"

- name: Deploy to GCP TESTNET VM
env:
PRIVATE_KEY: ${{ secrets.GCP_TESTNET_SSH_PRIVATE_KEY }}
Expand All @@ -51,5 +63,4 @@ 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:${{ env.REF }}' && docker run -d --name rooch --restart unless-stopped -v /data:/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}}\"}}}]}}'"
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST bash -c "'sleep 30' && docker image prune -a -f && docker ps | grep rooch | grep -v faucet | awk '{print \$1}' | xargs -r docker stop && docker ps -a | grep rooch | grep -v faucet | 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 /data:/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}}\"}}}]}}'"
7 changes: 7 additions & 0 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ jobs:
tags: |
ghcr.io/rooch-network/rooch:${{ steps.docker_meta.outputs.version }}
ghcr.io/rooch-network/rooch:main
- name: Save Docker tag as artifact
run: echo "${{ steps.docker_meta.outputs.version }}" > docker_tag.txt
- name: Upload Docker tag artifact
uses: actions/upload-artifact@v2
with:
name: docker_tag
path: docker_tag.txt

build-debug-rooch-docker:
name: Build and Deploy Debug Rooch Docker
Expand Down

0 comments on commit 3b7f9dd

Please sign in to comment.