-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
092333a
commit 1851d6d
Showing
1 changed file
with
27 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,8 @@ | |
# 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 }} )' | ||
name: '[M] Build and Release Ten Gateway Frontend' | ||
run-name: '[M] Build and Release Frontend (${{ github.event.inputs.testnet_type }})' | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
|
@@ -31,17 +31,16 @@ on: | |
options: | ||
- "primary" | ||
- "dexynth" | ||
gateway_url: | ||
description: "Gateway URL (optional)" | ||
required: false | ||
tag: | ||
description: "Tag to build and push (leave empty for latest)" | ||
required: true | ||
default: '' | ||
|
||
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: | ||
build-and-release: | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: ${{ github.event.inputs.testnet_type }} | ||
|
@@ -51,93 +50,42 @@ jobs: | |
run: | | ||
INSTANCE_SUFFIX="" | ||
INSTANCE_PREFIX="" | ||
if [[ "${{ github.event.inputs.instance_type }}" != "primary" ]]; then | ||
INSTANCE_SUFFIX="-${{ github.event.inputs.instance_type }}" | ||
INSTANCE_PREFIX="${{ github.event.inputs.instance_type }}-" | ||
fi | ||
if [[ -z "${{ github.event.inputs.gateway_url }}" ]]; then | ||
GATEWAY_URL="${{ env.GATEWAY_URL }}" | ||
else | ||
GATEWAY_URL="${{ github.event.inputs.gateway_url }}" | ||
fi | ||
echo "INSTANCE_SUFFIX=$INSTANCE_SUFFIX" >> $GITHUB_ENV | ||
echo "INSTANCE_PREFIX=$INSTANCE_PREFIX" >> $GITHUB_ENV | ||
echo "GATEWAY_URL=$GATEWAY_URL" >> $GITHUB_ENV | ||
DNS_NAME_LABEL_GATEWAY_FE="${{ github.event.inputs.testnet_type }}-ten-gateway${INSTANCE_SUFFIX}" | ||
IMAGE_NAME_GATEWAY_FE="${{ github.event.inputs.testnet_type }}-fe-ten-gateway${INSTANCE_SUFFIX}" | ||
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 | ||
- name: "Build and Push Docker Image" | ||
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 }} | ||
VERSION="${{ github.event.inputs.tag }}" | ||
if [[ -z "$VERSION" ]]; then | ||
VERSION=$(git describe --tags `git rev-list --tags --max-count=1` || echo "latest") | ||
fi | ||
echo "VERSION=${VERSION}" | ||
- name: 'Build and Push Docker Image' | ||
run: | | ||
DOCKER_BUILDKIT=1 docker build \ | ||
--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 }} \ | ||
-t ${{ env.IMAGE_NAME_GATEWAY_FE }}:${VERSION} \ | ||
-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 | ||
docker push ${{ env.IMAGE_NAME_GATEWAY_FE }}:${VERSION} |