-
Notifications
You must be signed in to change notification settings - Fork 39
145 lines (128 loc) · 5.32 KB
/
manual-deploy-ten-gateway-frontend.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Deploys TEN Gateway Frontend on Azure for Testnet
# Builds the TEN Gateway image, pushes the image to dockerhub and starts the TEN Gateway on Azure VM
# This action requires the following environment variables to be set:
# - DOCKER_BUILD_TAG_GATEWAY_FE
# - GATEWAY_URL
# - NETWORK_NAME
# - TENSCAN_URL
# If we are deploying to a non primary instance all those variables should be prefixed with the instance name
# example: DEXYNTH_GATEWAY_URL
name: "[M] Deploy Ten Gateway Frontend"
run-name: "[M] Deploy Ten Gateway Frontend ( ${{ 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"
instance_type:
description: "Instance"
required: true
default: "primary"
type: choice
options:
- "primary"
- "DEXYNTH"
jobs:
validate-inputs:
runs-on: ubuntu-latest
steps:
- name: "Check if deployment is allowed"
run: |
if [[ "${{ github.event.inputs.instance_type }}" == "DEXYNTH" && "${{ github.event.inputs.testnet_type }}" != "sepolia-testnet" ]]; then
echo "Error: Dexynth can only be deployed to sepolia-testnet."
exit 1
fi
build-and-deploy:
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.testnet_type }}
steps:
- name: "Set up environment variables"
id: setup_env
run: |
INSTANCE_SUFFIX=""
INSTANCE_PREFIX=""
if [[ "${{ github.event.inputs.instance_type }}" != "primary" ]]; then
INSTANCE_SUFFIX="_${{ github.event.inputs.instance_type }}"
INSTANCE_SUFFIX2="-${{ github.event.inputs.instance_type }}"
INSTANCE_PREFIX="${{ github.event.inputs.instance_type }}_"
fi
echo "INSTANCE_SUFFIX=$INSTANCE_SUFFIX" >> $GITHUB_ENV
echo "INSTANCE_PREFIX=$INSTANCE_PREFIX" >> $GITHUB_ENV
DNS_NAME_LABEL_GATEWAY_FE="${{ github.event.inputs.testnet_type }}-ten-gateway${INSTANCE_SUFFIX2,,}"
IMAGE_NAME_GATEWAY_FE="${{ github.event.inputs.testnet_type }}-fe-ten-gateway${INSTANCE_SUFFIX2,,}"
echo "DNS_NAME_LABEL_GATEWAY_FE=$DNS_NAME_LABEL_GATEWAY_FE" >> $GITHUB_ENV
echo "IMAGE_NAME_GATEWAY_FE=$IMAGE_NAME_GATEWAY_FE" >> $GITHUB_ENV
# Set instance-specific variables
declare -a VAR_NAMES=(
"DOCKER_BUILD_TAG_GATEWAY_FE"
"GATEWAY_URL"
"NETWORK_NAME"
"TENSCAN_URL"
)
for VAR_NAME in "${VAR_NAMES[@]}"; do
FULL_VAR_NAME="${INSTANCE_PREFIX}${VAR_NAME}"
VAR_VALUE=$(jq -r --arg key "$FULL_VAR_NAME" '.[$key] // empty' <<< '${{ toJson(vars) }}')
if [[ -n "$VAR_VALUE" ]]; then
echo "${VAR_NAME}=${VAR_VALUE}" >> $GITHUB_ENV
else
echo "Warning: ${FULL_VAR_NAME} not found in vars" >&2
fi
done
- name: "Print GitHub variables"
run: |
echo "Selected Testnet Type: ${{ github.event.inputs.testnet_type }}"
echo "Selected Instance Type: ${{ github.event.inputs.instance_type }}"
echo "DNS_NAME_LABEL_GATEWAY_FE: $DNS_NAME_LABEL_GATEWAY_FE"
echo "IMAGE_NAME_GATEWAY_FE: $IMAGE_NAME_GATEWAY_FE"
echo "DOCKER_BUILD_TAG_GATEWAY_FE: $DOCKER_BUILD_TAG_GATEWAY_FE"
echo "GATEWAY_URL: $GATEWAY_URL"
echo "NETWORK_NAME: $NETWORK_NAME"
echo "TENSCAN_URL: $TENSCAN_URL"
- uses: actions/checkout@v4
- name: "Extract branch name"
shell: bash
run: |
echo "Branch Name: ${GITHUB_REF_NAME}"
echo "BRANCH_NAME=${GITHUB_REF_NAME}" >> $GITHUB_ENV
- name: "Set up Docker"
uses: docker/[email protected]
- name: "Login to Azure docker registry"
uses: azure/docker-login@v1
with:
login-server: testnetobscuronet.azurecr.io
username: testnetobscuronet
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: "Login via Azure CLI"
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: "Build and Push Docker Image"
run: |
DOCKER_BUILDKIT=1 docker build \
--build-arg NEXT_PUBLIC_API_HOST_ENVIRONMENT="${{ github.event.inputs.testnet_type }}" \
--build-arg NEXT_PUBLIC_NETWORK_NAME="${{ env.NETWORK_NAME }}" \
--build-arg NEXT_PUBLIC_TENSCAN_URL="${{ env.TENSCAN_URL }}" \
--build-arg NEXT_PUBLIC_GATEWAY_URL="${{ env.GATEWAY_URL }}" \
-t "${{ env.DOCKER_BUILD_TAG_GATEWAY_FE }}" \
-f ./tools/walletextension/frontend/Dockerfile .
docker push "${{ env.DOCKER_BUILD_TAG_GATEWAY_FE }}"
- name: "Deploy Gateway FE to Azure Container Instances"
uses: "azure/aci-deploy@v1"
with:
resource-group: ${{ secrets.RESOURCE_GROUP }}
dns-name-label: ${{ env.DNS_NAME_LABEL_GATEWAY_FE }}
image: ${{ env.DOCKER_BUILD_TAG_GATEWAY_FE }}
name: ${{ env.IMAGE_NAME_GATEWAY_FE }}
location: "uksouth"
restart-policy: "Never"
ports: "80"
cpu: 2
memory: 2