Skip to content

[M] Deploy Uniswap ( dev-testnet ) #98

[M] Deploy Uniswap ( dev-testnet )

[M] Deploy Uniswap ( dev-testnet ) #98

# Deploys Uniswap on Azure for Testnet
# Builds the Uniswap network image, pushes the image to dockerhub and starts the Uniswap on azure
#
# It exposes the following ports:
# HTTP: 80,
#
# Exposes the following addresses: (only accessible internally)
# testnet-uniswap.uksouth.azurecontainer.io
name: '[M] Deploy Uniswap'
run-name: '[M] Deploy Uniswap ( ${{ github.event.inputs.testnet_type }} )'
on:
workflow_dispatch:
inputs:
testnet_type:
description: 'Testnet Type'
required: true
default: 'dev-testnet'
type: choice
options:
- 'dev-testnet'
- 'uat-testnet'
- 'sepolia-testnet'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Docker
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: obscuronet/${{ github.event.inputs.testnet_type }}_uniswap_testnet:latest
file: ./Dockerfile
- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
# This will fail some deletions due to resource dependencies ( ie. you must first delete the vm before deleting the disk)
- name: 'Delete deployed VMs'
uses: azure/CLI@v1
with:
inlineScript: |
$(az resource list --tag ${{ github.event.inputs.testnet_type }}_uniswap_resources=true --query '[]."id"' -o tsv | xargs -n1 az resource delete --verbose -g Testnet --ids) || true
# This will clean up any lingering dependencies - might fail if there are no resources to cleanup
- name: 'Delete VMs dependencies'
uses: azure/CLI@v1
with:
inlineScript: |
$(az resource list --tag ${{ github.event.inputs.testnet_type }}_uniswap_resources=true --query '[]."id"' -o tsv | xargs -n1 az resource delete --verbose -g Testnet --ids) || true
- name: 'Create VM for Uniswap node-0 on Azure'
uses: azure/CLI@v1
with:
inlineScript: |
az vm create -g Testnet -n "${{ github.event.inputs.testnet_type }}-uniswap-0-${{ GITHUB.RUN_NUMBER }}" \
--admin-username obscurouser --admin-password "${{ secrets.UNISWAP_NODE_VM_PWD }}" \
--public-ip-address-dns-name "${{ github.event.inputs.testnet_type }}-uniswap-0-${{ GITHUB.RUN_NUMBER }}" \
--tags deploygroup=${{ github.event.inputs.testnet_type }}-uniswap-${{ GITHUB.RUN_NUMBER }} ${{ github.event.inputs.testnet_type }}_uniswap_resources=true \
--vnet-name ${{ github.event.inputs.testnet_type }}-uniswap01VNET --subnet ${{ github.event.inputs.testnet_type }}-uniswap01Subnet \
--size Standard_D4as_v4 --image Canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:20.04.202206220 \
--public-ip-sku Basic --authentication-type password
- name: 'Open Uniswap node-${{ matrix.host_id }} ports on Azure'
uses: azure/CLI@v1
with:
inlineScript: |
az vm open-port -g Testnet -n "${{ github.event.inputs.testnet_type }}-uniswap-0-${{ GITHUB.RUN_NUMBER }}" --port 80
- name: 'Start Uniswap node-${{ matrix.host_id }} on Azure'
uses: azure/CLI@v1
with:
inlineScript: |
az vm run-command invoke -g Testnet -n "${{ github.event.inputs.testnet_type }}-uniswap-0-${{ GITHUB.RUN_NUMBER }}" \
--command-id RunShellScript \
--scripts 'mkdir -p /home/uniswap \
&& sudo apt-get update \
&& curl -fsSL https://get.docker.com -o get-docker.sh && sh ./get-docker.sh \
&& docker run -d --name datadog-agent \
-e DD_API_KEY=${{ secrets.DD_API_KEY }} \
-e DD_LOGS_ENABLED=true \
-e DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true \
-e DD_CONTAINER_EXCLUDE_LOGS="name:datadog-agent" \
-e DD_SITE="datadoghq.eu" \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /proc/:/host/proc/:ro \
-v /opt/datadog-agent/run:/opt/datadog-agent/run:rw \
-v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
datadog/agent:latest \
&& sudo docker run -d -p 80:80 \
--entrypoint /uniswap/deploy.sh obscuronet/${{ github.event.inputs.testnet_type }}_uniswap_testnet:latest \
--pk_string=${{ secrets.FAUCET_PK_STRING }} --addr=${{ secrets.FAUCET_ADDR }} \
--faucet_addr=${{ github.event.inputs.testnet_type }}-faucet.uksouth.azurecontainer.io \
--we_host=erpc.${{ github.event.inputs.testnet_type }}.obscu.ro '
# - name: 'Remove existing backend nodes from the load balancer'
# run: ./.github/workflows/runner-scripts/clear-loadbalancer.sh
# - name: 'Create VM for Uniswap node-${{ matrix.host_id }} on Azure'
# uses: azure/CLI@v1
# with:
# inlineScript: |
# az network nic ip-config address-pool add \
# --address-pool Backend-Pool-${{ github.event.inputs.testnet_type }}-Uniswap \
# --ip-config-name ipconfig-${{ github.event.inputs.testnet_type }}-Uniswap-0-${{ GITHUB.RUN_NUMBER }} \
# --nic-name ${{ github.event.inputs.testnet_type }}-Uniswap-0-${{ GITHUB.RUN_NUMBER }}VMNic \
# --resource-group Testnet \
# --lb-name ${{ github.event.inputs.testnet_type }}-loadbalancer-uniswap
#