sonr/.github/workflows/testnet-hetzner.yml

93 lines
3.2 KiB
YAML

name: cloud testnet
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+' # ignore rc
# https://github.com/<org>/<repo>/settings/secrets/actions/new
# - HCLOUD_TOKEN
# - SSH_PRIVATE_KEY
env:
GO_VERSION: 1.21.0
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
LOCALIC_PORT: 8080
LOCALIC_AUTH_KEY: ""
HETZNER_SSH_KEY: "reece-hetzner"
# HETZNER_MACHINE_TYPE: "cpx31" # shared 4vCPU ($7/Mo)
HETZNER_MACHINE_TYPE: "ccx23" # dedicated 4 CPU 16GB Ram ($25/Mo)
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
launch-testnet:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: TimDaub/hetzner-cloud-deploy-server-action@v2
with:
# gh-actions-tn-v1.0.0
server-name: "gh-actions-tn-${{github.ref_name}}"
server-image: "ubuntu-22.04"
server-type: ${{ env.HETZNER_MACHINE_TYPE }}
ssh-key-name: ${{ env.HETZNER_SSH_KEY }}
delete-server: false
startup-timeout: 40000 # ms
hcloud-token: ${{ secrets.HCLOUD_TOKEN }}
- name: Set env variables
run: |
mkdir -p ~/.ssh/ && ssh-keyscan -H $SERVER_IPV4 >> ~/.ssh/known_hosts
echo "SERVER_IPV4_ADDR=$SERVER_IPV4" >> $GITHUB_ENV
echo "GITHUB_SHA=${{github.sha}}" >> $GITHUB_ENV
echo "GITHUB_REF_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
echo "LOCALIC_PORT=${{ env.LOCALIC_PORT }}" >> $GITHUB_ENV
- uses: JasonEtco/create-an-issue@v2.9.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filename: .github/testnet.md
update_existing: true
- name: Testnet setup
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ env.SERVER_IPV4_ADDR }}
username: root
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt -y install make gcc jq bison ca-certificates curl
wget https://go.dev/dl/go1.22.1.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.22.1.linux-amd64.tar.gz
echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.bashrc
export PATH=$PATH:/usr/local/go/bin
bash # idk if I can use this or not
sudo DEBIAN_FRONTEND=noninteractive apt-get remove -y containerd.io
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install docker.io docker-compose
sudo apt-get update
wget https://github.com/strangelove-ventures/interchaintest/releases/download/v8.2.0/local-ic && chmod +x local-ic
sudo mv local-ic /usr/local/bin
git clone https://github.com/strangelove-ventures/heighliner.git && cd heighliner
go build && chmod +x heighliner
sudo mv heighliner /usr/local/bin
cd ~/
git clone https://github.com/${{ github.repository }}.git chain && cd chain
git checkout ${{ github.ref_name }}
make local-image
sudo screen -S testnet -d -m local-ic start ibc-testnet --api-address=0.0.0.0 --api-port=${{ env.LOCALIC_PORT }} --auth-key=${{ env.LOCALIC_AUTH_KEY }}