Skip to content

Commit

Permalink
Convert remaining GH action scripts to env vars (#1615)
Browse files Browse the repository at this point in the history
  • Loading branch information
BedrockSquirrel authored Oct 20, 2023
1 parent ebcc4aa commit 85f05f9
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 199 deletions.
57 changes: 0 additions & 57 deletions .github/workflows/manual-deploy-dev-obscuroscan.yml

This file was deleted.

43 changes: 14 additions & 29 deletions .github/workflows/manual-deploy-obscuro-gateway-database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ on:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.testnet_type }}
steps:
- name: 'Print GitHub variables'
# This is a useful record of what the environment variables were at the time the job ran, for debugging and reference
run: |
echo "GitHub Variables = ${{ toJSON(vars) }}"
- uses: actions/checkout@v3

- name: 'Extract branch name'
Expand All @@ -28,28 +35,6 @@ jobs:
echo "Branch Name: ${GITHUB_REF_NAME}"
echo "BRANCH_NAME=${GITHUB_REF_NAME}" >> $GITHUB_ENV
- name: 'Set Obscuro Gateway variables for UAT testnet'
if: ${{ github.event.inputs.testnet_type == 'uat-testnet' }}
run: |
echo "OBSCURO_GATEWAY_DB_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/obscuro_gateway_mariadb_uat_testnet:latest" >> $GITHUB_ENV
echo "RESOURCE_STARTING_NAME=uat-testnet" >> $GITHUB_ENV
echo "RESOURCE_TAG_NAME=obscuro-gateway-db-testnet-latest" >> $GITHUB_ENV
- name: 'Set Obscuro Gateway variables for dev-testnet'
if: ${{ github.event.inputs.testnet_type == 'dev-testnet' }}
run: |
echo "OBSCURO_GATEWAY_DB_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/obscuro_gateway_mariadb_dev_testnet:latest" >> $GITHUB_ENV
echo "RESOURCE_STARTING_NAME=dev-testnet" >> $GITHUB_ENV
echo "RESOURCE_TAG_NAME=obscuro-gateway-db-dev-testnet-latest" >> $GITHUB_ENV
- name: 'Set Obscuro Gateway variables for sepolia-testnet'
if: ${{ github.event.inputs.testnet_type == 'sepolia-testnet' }}
run: |
echo "OBSCURO_GATEWAY_DB_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/obscuro_gateway_mariadb_sepolia_testnet:latest" >> $GITHUB_ENV
echo "RESOURCE_STARTING_NAME=sepolia-testnet" >> $GITHUB_ENV
echo "RESOURCE_TAG_NAME=obscuro-gateway-db-sepolia-testnet-latest" >> $GITHUB_ENV
- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
Expand All @@ -60,7 +45,7 @@ jobs:
uses: azure/CLI@v1
with:
inlineScript: |
$(az resource list --tag ${{env.RESOURCE_TAG_NAME}}=true --query '[]."id"' -o tsv | xargs -n1 az resource delete --verbose -g Testnet --ids) || true
$(az resource list --tag ${{ vars.AZURE_DEPLOY_GROUP_GATEWAY_DB }}=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'
Expand All @@ -74,18 +59,18 @@ jobs:
uses: azure/CLI@v1
with:
inlineScript: |
az vm create -g Testnet -n "${{env.RESOURCE_STARTING_NAME}}-OG-MariaDB-${{ GITHUB.RUN_NUMBER }}" \
az vm create -g Testnet -n "${{ github.event.inputs.testnet_type }}-OG-MariaDB-${{ GITHUB.RUN_NUMBER }}" \
--admin-username obscurouser --admin-password "${{ secrets.OBSCURO_NODE_VM_PWD }}" \
--public-ip-address-dns-name "obscurogateway-mariadb-${{env.RESOURCE_STARTING_NAME}}" \
--tags deploygroup=ObscuroGateway-mariaDB-${{env.RESOURCE_STARTING_NAME}}-${{ GITHUB.RUN_NUMBER }} ${{env.RESOURCE_TAG_NAME}}=true \
--public-ip-address-dns-name "obscurogateway-mariadb-${{ github.event.inputs.testnet_type }}" \
--tags deploygroup=ObscuroGateway-mariaDB-${{ github.event.inputs.testnet_type }}-${{ GITHUB.RUN_NUMBER }} ${{ vars.AZURE_DEPLOY_GROUP_GATEWAY_DB }}=true \
--size Standard_D4_v5 --image Canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:latest \
--public-ip-sku Basic --authentication-type password
- name: 'Open Obscuro Gateway db ports on Azure'
uses: azure/CLI@v1
with:
inlineScript: |
az vm open-port -g Testnet -n "${{env.RESOURCE_STARTING_NAME}}-OG-MariaDB-${{ GITHUB.RUN_NUMBER }}" --port 3306
az vm open-port -g Testnet -n "${{ github.event.inputs.testnet_type }}-OG-MariaDB-${{ GITHUB.RUN_NUMBER }}" --port 3306
# To overcome issues with critical VM resources being unavailable, we need to wait for the VM to be ready
- name: 'Allow time for VM initialization'
Expand All @@ -96,7 +81,7 @@ jobs:
uses: azure/CLI@v1
with:
inlineScript: |
az vm run-command invoke -g Testnet -n "${{env.RESOURCE_STARTING_NAME}}-OG-MariaDB-${{ GITHUB.RUN_NUMBER }}" \
az vm run-command invoke -g Testnet -n "${{ github.event.inputs.testnet_type }}-OG-MariaDB-${{ GITHUB.RUN_NUMBER }}" \
--command-id RunShellScript \
--scripts 'mkdir -p /home/obscuro \
&& sudo apt-get update \
Expand All @@ -119,7 +104,7 @@ jobs:
-v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
datadog/agent:latest \
&& cd /home/obscuro/go-obscuro/ \
&& docker run -d --name ${{env.RESOURCE_STARTING_NAME}}-OG-MariaDB-${{ GITHUB.RUN_NUMBER }} \
&& docker run -d --name ${{ github.event.inputs.testnet_type }}-OG-MariaDB-${{ GITHUB.RUN_NUMBER }} \
-p 3306:3306 \
-e MARIADB_ROOT_PASSWORD=${{ secrets.OBSCURO_GATEWAY_MARIADB_ROOT_PWD }} \
-e MARIADB_USER=obscurouser \
Expand Down
57 changes: 20 additions & 37 deletions .github/workflows/manual-deploy-obscuro-gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ on:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.testnet_type }}
steps:
- name: 'Print GitHub variables'
# This is a useful record of what the environment variables were at the time the job ran, for debugging and reference
run: |
echo "GitHub Variables = ${{ toJSON(vars) }}"
- uses: actions/checkout@v3

- name: 'Extract branch name'
Expand All @@ -31,30 +38,6 @@ jobs:
- name: 'Set up Docker'
uses: docker/setup-buildx-action@v1

- name: 'Set Obscuro Gateway variables for testnet'
if: ${{ github.event.inputs.testnet_type == 'uat-testnet' }}
run: |
echo "OBSCURO_GATEWAY_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/obscuro_gateway_uat_testnet:latest" >> $GITHUB_ENV
echo "OBSCURO_GATEWAY_NODE_HOST=erpc.uat-testnet.obscu.ro" >> $GITHUB_ENV
echo "RESOURCE_STARTING_NAME=uat-testnet" >> $GITHUB_ENV
echo "RESOURCE_TAG_NAME=obscuro-gateway-uat-testnet-latest" >> $GITHUB_ENV
- name: 'Set Obscuro Gateway variables for dev-testnet'
if: ${{ github.event.inputs.testnet_type == 'dev-testnet' }}
run: |
echo "OBSCURO_GATEWAY_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/obscuro_gateway_dev_testnet:latest" >> $GITHUB_ENV
echo "OBSCURO_GATEWAY_NODE_HOST=erpc.dev-testnet.obscu.ro" >> $GITHUB_ENV
echo "RESOURCE_STARTING_NAME=dev-testnet" >> $GITHUB_ENV
echo "RESOURCE_TAG_NAME=obscuro-gateway-dev-testnet-latest" >> $GITHUB_ENV
- name: 'Set Obscuro Gateway variables for sepolia-testnet'
if: ${{ github.event.inputs.testnet_type == 'sepolia-testnet' }}
run: |
echo "OBSCURO_GATEWAY_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/obscuro_gateway_sepolia_testnet:latest" >> $GITHUB_ENV
echo "OBSCURO_GATEWAY_NODE_HOST=erpc.sepolia-testnet.obscu.ro" >> $GITHUB_ENV
echo "RESOURCE_STARTING_NAME=sepolia-testnet" >> $GITHUB_ENV
echo "RESOURCE_TAG_NAME=obscuro-gateway-sepolia-testnet-latest" >> $GITHUB_ENV
- name: 'Login to Azure docker registry'
uses: azure/docker-login@v1
with:
Expand All @@ -69,41 +52,41 @@ jobs:

- name: Build and Push Docker Image
run: |
DOCKER_BUILDKIT=1 docker build -t ${{ env.OBSCURO_GATEWAY_BUILD_TAG }} -f ./tools/walletextension/Dockerfile .
docker push ${{ env.OBSCURO_GATEWAY_BUILD_TAG }}
DOCKER_BUILDKIT=1 docker build -t ${{ vars.DOCKER_BUILD_TAG_GATEWAY }} -f ./tools/walletextension/Dockerfile .
docker push ${{ vars.DOCKER_BUILD_TAG_GATEWAY }}
# 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 ${{env.RESOURCE_TAG_NAME}}=true --query '[]."id"' -o tsv | xargs -n1 az resource delete --verbose -g Testnet --ids) || true
$(az resource list --tag ${{ vars.AZURE_DEPLOY_GROUP_GATEWAY }}=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 ${{env.RESOURCE_TAG_NAME}}=true --query '[]."id"' -o tsv | xargs -n1 az resource delete --verbose -g Testnet --ids) || true
$(az resource list --tag ${{ vars.AZURE_DEPLOY_GROUP_GATEWAY }}=true --query '[]."id"' -o tsv | xargs -n1 az resource delete --verbose -g Testnet --ids) || true
- name: 'Create VM for Gateway node on Azure'
uses: azure/CLI@v1
with:
inlineScript: |
az vm create -g Testnet -n "${{env.RESOURCE_STARTING_NAME}}-OG-${{ GITHUB.RUN_NUMBER }}" \
az vm create -g Testnet -n "${{ github.event.inputs.testnet_type }}-OG-${{ GITHUB.RUN_NUMBER }}" \
--admin-username obscurouser --admin-password "${{ secrets.OBSCURO_NODE_VM_PWD }}" \
--public-ip-address-dns-name "obscurogateway-${{env.RESOURCE_STARTING_NAME}}" \
--tags deploygroup=ObscuroGateway-${{env.RESOURCE_STARTING_NAME}}-${{ GITHUB.RUN_NUMBER }} ${{env.RESOURCE_TAG_NAME}}=true \
--vnet-name ObscuroGateway-${{env.RESOURCE_STARTING_NAME}}-01VNET --subnet ObscuroGateway-${{env.RESOURCE_STARTING_NAME}}-01Subnet \
--public-ip-address-dns-name "obscurogateway-${{ github.event.inputs.testnet_type }}" \
--tags deploygroup=ObscuroGateway-${{ github.event.inputs.testnet_type }}-${{ GITHUB.RUN_NUMBER }} ${{ vars.AZURE_DEPLOY_GROUP_GATEWAY }}=true \
--vnet-name ObscuroGateway-${{ github.event.inputs.testnet_type }}-01VNET --subnet ObscuroGateway-${{ github.event.inputs.testnet_type }}-01Subnet \
--size Standard_D4_v5 --image Canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:latest \
--public-ip-sku Basic --authentication-type password
- name: 'Open Obscuro node-${{ matrix.host_id }} ports on Azure'
uses: azure/CLI@v1
with:
inlineScript: |
az vm open-port -g Testnet -n "${{env.RESOURCE_STARTING_NAME}}-OG-${{ GITHUB.RUN_NUMBER }}" --port 80,81
az vm open-port -g Testnet -n "${{ github.event.inputs.testnet_type }}-OG-${{ GITHUB.RUN_NUMBER }}" --port 80,81
# To overcome issues with critical VM resources being unavailable, we need to wait for the VM to be ready
- name: 'Allow time for VM initialization'
Expand All @@ -114,7 +97,7 @@ jobs:
uses: azure/CLI@v1
with:
inlineScript: |
az vm run-command invoke -g Testnet -n "${{env.RESOURCE_STARTING_NAME}}-OG-${{ GITHUB.RUN_NUMBER }}" \
az vm run-command invoke -g Testnet -n "${{ github.event.inputs.testnet_type }}-OG-${{ GITHUB.RUN_NUMBER }}" \
--command-id RunShellScript \
--scripts 'mkdir -p /home/obscuro \
&& sudo apt-get update \
Expand All @@ -137,8 +120,8 @@ jobs:
-v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
datadog/agent:latest \
&& cd /home/obscuro/go-obscuro/ \
&& docker run -d -p 80:80 -p 81:81 --name ${{env.RESOURCE_STARTING_NAME}}-OG-${{ GITHUB.RUN_NUMBER }} \
&& docker run -d -p 80:80 -p 81:81 --name ${{ github.event.inputs.testnet_type }}-OG-${{ GITHUB.RUN_NUMBER }} \
-e OBSCURO_GATEWAY_VERSION="${{ GITHUB.RUN_NUMBER }}-${{ GITHUB.SHA }}" \
${{ env.OBSCURO_GATEWAY_BUILD_TAG }} \
./wallet_extension_linux -host=0.0.0.0 -port=80 -portWS=81 -nodeHost=${{ env.OBSCURO_GATEWAY_NODE_HOST }} \
${{ vars.DOCKER_BUILD_TAG_GATEWAY }} \
./wallet_extension_linux -host=0.0.0.0 -port=80 -portWS=81 -nodeHost=${{ vars.L2_RPC_URL_VALIDATOR }} \
-logPath=sys_out -dbType=mariaDB -dbConnectionURL="obscurouser:${{ secrets.OBSCURO_GATEWAY_MARIADB_USER_PWD }}@tcp(obscurogateway-mariadb-${{ github.event.inputs.testnet_type }}.uksouth.cloudapp.azure.com:3306)/ogdb"'
42 changes: 14 additions & 28 deletions .github/workflows/manual-deploy-obscuro-scan-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,19 @@ on:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.testnet_type }}
steps:
- name: 'Print GitHub variables'
# This is a useful record of what the environment variables were at the time the job ran, for debugging and reference
run: |
echo "GitHub Variables = ${{ toJSON(vars) }}"
- uses: actions/checkout@v3

- name: 'Set up Docker'
uses: docker/setup-buildx-action@v1

- name: 'Set Obscuro Scan variables for sepolia-testnet'
if: ${{ github.event.inputs.testnet_type == 'sepolia-testnet' }}
run: |
echo "OBSCURO_SCAN_FE_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/fe_obscuro_scan_sepolia_testnet:latest" >> $GITHUB_ENV
echo "OBSCURO_SCAN_API_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/api_obscuro_scan_sepolia_testnet:latest" >> $GITHUB_ENV
echo "OBSCURO_SCAN_NODE_HOST=erpc.sepolia-testnet.obscu.ro" >> $GITHUB_ENV
- name: 'Set Obscuro Scan variables for uat-testnet'
if: ${{ github.event.inputs.testnet_type == 'uat-testnet' }}
run: |
echo "OBSCURO_SCAN_FE_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/fe_obscuro_scan_uat_testnet:latest" >> $GITHUB_ENV
echo "OBSCURO_SCAN_API_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/api_obscuro_scan_uat_testnet:latest" >> $GITHUB_ENV
echo "OBSCURO_SCAN_NODE_HOST=erpc.uat-testnet.obscu.ro" >> $GITHUB_ENV
- name: 'Set Obscuro Scan variables for dev-testnet'
if: ${{ github.event.inputs.testnet_type == 'dev-testnet' }}
run: |
echo "OBSCURO_SCAN_FE_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/fe_obscuro_scan_dev_testnet:latest" >> $GITHUB_ENV
echo "OBSCURO_SCAN_API_BUILD_TAG=testnetobscuronet.azurecr.io/obscuronet/api_obscuro_scan_dev_testnet:latest" >> $GITHUB_ENV
echo "OBSCURO_SCAN_NODE_HOST=erpc.dev-testnet.obscu.ro" >> $GITHUB_ENV
- name: 'Login to Azure docker registry'
uses: azure/docker-login@v1
with:
Expand All @@ -60,20 +46,20 @@ jobs:

- name: Build and Push Docker FE Image
run: |
DOCKER_BUILDKIT=1 docker build -t ${{ env.OBSCURO_SCAN_FE_BUILD_TAG }} -f ./tools/obscuroscan_v2/frontend/Dockerfile .
docker push ${{ env.OBSCURO_SCAN_FE_BUILD_TAG }}
DOCKER_BUILDKIT=1 docker build -t ${{ vars.DOCKER_BUILD_TAG_SCAN_FE }} -f ./tools/obscuroscan_v2/frontend/Dockerfile .
docker push ${{ vars.DOCKER_BUILD_TAG_SCAN_FE }}
- name: Build and Push Docker API Image
run: |
DOCKER_BUILDKIT=1 docker build -t ${{ env.OBSCURO_SCAN_API_BUILD_TAG }} -f ./tools/obscuroscan_v2/backend/Dockerfile .
docker push ${{ env.OBSCURO_SCAN_API_BUILD_TAG }}
DOCKER_BUILDKIT=1 docker build -t ${{ vars.DOCKER_BUILD_TAG_SCAN_API }} -f ./tools/obscuroscan_v2/backend/Dockerfile .
docker push ${{ vars.DOCKER_BUILD_TAG_SCAN_API }}
- name: 'Deploy FE to Azure Container Instances'
uses: 'azure/aci-deploy@v1'
with:
resource-group: ${{ secrets.RESOURCE_GROUP }}
dns-name-label: ${{ github.event.inputs.testnet_type }}-obscuro-scan
image: ${{ env.OBSCURO_SCAN_FE_BUILD_TAG }}
image: ${{ vars.DOCKER_BUILD_TAG_SCAN_FE }}
name: ${{ github.event.inputs.testnet_type }}-fe-obscuro-scan
location: 'uksouth'
restart-policy: 'Never'
Expand All @@ -88,11 +74,11 @@ jobs:
with:
resource-group: ${{ secrets.RESOURCE_GROUP }}
dns-name-label: ${{ github.event.inputs.testnet_type }}-api-obscuro-scan
image: ${{ env.OBSCURO_SCAN_API_BUILD_TAG }}
image: ${{ vars.DOCKER_BUILD_TAG_SCAN_API }}
name: ${{ github.event.inputs.testnet_type }}-api-obscuro-scan
location: 'uksouth'
restart-policy: 'Never'
command-line: ./cmd/backend --nodeHostAddress http://${{ env.OBSCURO_SCAN_NODE_HOST }}:80 --serverAddress 0.0.0.0:80
command-line: ./cmd/backend --nodeHostAddress http://${{ vars.L2_RPC_URL_VALIDATOR }}:80 --serverAddress 0.0.0.0:80
ports: '80'
cpu: 2
memory: 2
Expand Down
Loading

0 comments on commit 85f05f9

Please sign in to comment.