From 276e23b54d96275fb84f650b1ad023304ec73bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDiga=20Kokelj?= Date: Fri, 23 Aug 2024 13:01:14 +0200 Subject: [PATCH] define env variables in a step --- .../manual-deploy-obscuro-gateway.yml | 61 ++++++++++++------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/.github/workflows/manual-deploy-obscuro-gateway.yml b/.github/workflows/manual-deploy-obscuro-gateway.yml index f2308f22f9..8afa56f478 100644 --- a/.github/workflows/manual-deploy-obscuro-gateway.yml +++ b/.github/workflows/manual-deploy-obscuro-gateway.yml @@ -39,29 +39,46 @@ jobs: runs-on: ubuntu-latest environment: name: ${{ github.event.inputs.testnet_type }} - env: - # Set environment variables based on the instance type - # (use the instance type as a prefix for the environment variables and avoid using the suffix for the primary instance) - INSTANCE_SUFFIX: ${{ github.event.inputs.instance_type == 'primary' && '' || format('-{}', github.event.inputs.instance_type) }} - INSTANCE_PREFIX: ${{ github.event.inputs.instance_type == 'primary' && '' || format('{}-', github.event.inputs.instance_type) }} - - # Set infrastructure variables which need to be unique for each environment & instance combination - PUBLIC_IP: ${{ github.event.inputs.testnet_type }}-OG-static${{ INSTANCE_SUFFIX }} - DNS_NAME: obscurogateway-${{ github.event.inputs.testnet_type }}${{ INSTANCE_SUFFIX }} - VM_NAME: ${{ github.event.inputs.testnet_type }}-OG-${{ github.run_number }}${{ INSTANCE_SUFFIX }} - DEPLOY_GROUP: ObscuroGateway-${{ github.event.inputs.testnet_type }}-${{ GITHUB.RUN_NUMBER }}${{ INSTANCE_SUFFIX }} - VNET_NAME: ObscuroGateway-${{ github.event.inputs.testnet_type }}-01VNET${{ INSTANCE_SUFFIX }} - SUBNET_NAME: ObscuroGateway-${{ github.event.inputs.testnet_type }}-01Subnet${{ INSTANCE_SUFFIX }} - - # Set variables that are unique for each instance type - DOCKER_BUILD_TAG_GATEWAY: ${{ vars[format('{}DOCKER_BUILD_TAG_GATEWAY', env.INSTANCE_PREFIX)] }} - AZURE_DEPLOY_GROUP_GATEWAY: ${{ vars[format('{}AZURE_DEPLOY_GROUP_GATEWAY', env.INSTANCE_PREFIX)] }} - L2_RPC_URL_VALIDATOR: ${{ vars[format('{}L2_RPC_URL_VALIDATOR', env.INSTANCE_PREFIX)] }} - GATEWAY_RATE_LIMIT_USER_COMPUTE_TIME: ${{ vars[format('{}GATEWAY_RATE_LIMIT_USER_COMPUTE_TIME', env.INSTANCE_PREFIX)] }} - GATEWAY_RATE_LIMIT_WINDOW: ${{ vars[format('{}GATEWAY_RATE_LIMIT_WINDOW', env.INSTANCE_PREFIX)] }} - GATEWAY_MAX_CONCURRENT_REQUESTS_PER_USER: ${{ vars[format('{}GATEWAY_MAX_CONCURRENT_REQUESTS_PER_USER', env.INSTANCE_PREFIX)] }} - steps: + - name: 'Set up environment variables' + id: setup_env + run: | + INSTANCE_PREFIX="${{ github.event.inputs.instance_type == 'primary' && '' || format('{}-', github.event.inputs.instance_type) | toUpper }}" + INSTANCE_SUFFIX="${{ github.event.inputs.instance_type == 'primary' && '' || format('-{}', github.event.inputs.instance_type) }}" + + echo "INSTANCE_SUFFIX=$INSTANCE_SUFFIX" >> $GITHUB_ENV + echo "INSTANCE_PREFIX=$INSTANCE_PREFIX" >> $GITHUB_ENV + + # Set infrastructure variables + PUBLIC_IP="${{ github.event.inputs.testnet_type }}-OG-static${INSTANCE_SUFFIX}" + DNS_NAME="obscurogateway-${{ github.event.inputs.testnet_type }}${INSTANCE_SUFFIX}" + VM_NAME="${{ github.event.inputs.testnet_type }}-OG-${{ github.run_number }}${INSTANCE_SUFFIX}" + DEPLOY_GROUP="ObscuroGateway-${{ github.event.inputs.testnet_type }}-${{ GITHUB.RUN_NUMBER }}${INSTANCE_SUFFIX}" + VNET_NAME="ObscuroGateway-${{ github.event.inputs.testnet_type }}-01VNET${INSTANCE_SUFFIX}" + SUBNET_NAME="ObscuroGateway-${{ github.event.inputs.testnet_type }}-01Subnet${INSTANCE_SUFFIX}" + + echo "PUBLIC_IP=$PUBLIC_IP" >> $GITHUB_ENV + echo "DNS_NAME=$DNS_NAME" >> $GITHUB_ENV + echo "VM_NAME=$VM_NAME" >> $GITHUB_ENV + echo "DEPLOY_GROUP=$DEPLOY_GROUP" >> $GITHUB_ENV + echo "VNET_NAME=$VNET_NAME" >> $GITHUB_ENV + echo "SUBNET_NAME=$SUBNET_NAME" >> $GITHUB_ENV + + # Set instance-specific variables + DOCKER_BUILD_TAG_GATEWAY="${{ vars[format('{}DOCKER_BUILD_TAG_GATEWAY', INSTANCE_PREFIX)] }}" + AZURE_DEPLOY_GROUP_GATEWAY="${{ vars[format('{}AZURE_DEPLOY_GROUP_GATEWAY', INSTANCE_PREFIX)] }}" + L2_RPC_URL_VALIDATOR="${{ vars[format('{}L2_RPC_URL_VALIDATOR', INSTANCE_PREFIX)] }}" + GATEWAY_RATE_LIMIT_USER_COMPUTE_TIME="${{ vars[format('{}GATEWAY_RATE_LIMIT_USER_COMPUTE_TIME', INSTANCE_PREFIX)] }}" + GATEWAY_RATE_LIMIT_WINDOW="${{ vars[format('{}GATEWAY_RATE_LIMIT_WINDOW', INSTANCE_PREFIX)] }}" + GATEWAY_MAX_CONCURRENT_REQUESTS_PER_USER="${{ vars[format('{}GATEWAY_MAX_CONCURRENT_REQUESTS_PER_USER', INSTANCE_PREFIX)] }}" + + echo "DOCKER_BUILD_TAG_GATEWAY=$DOCKER_BUILD_TAG_GATEWAY" >> $GITHUB_ENV + echo "AZURE_DEPLOY_GROUP_GATEWAY=$AZURE_DEPLOY_GROUP_GATEWAY" >> $GITHUB_ENV + echo "L2_RPC_URL_VALIDATOR=$L2_RPC_URL_VALIDATOR" >> $GITHUB_ENV + echo "GATEWAY_RATE_LIMIT_USER_COMPUTE_TIME=$GATEWAY_RATE_LIMIT_USER_COMPUTE_TIME" >> $GITHUB_ENV + echo "GATEWAY_RATE_LIMIT_WINDOW=$GATEWAY_RATE_LIMIT_WINDOW" >> $GITHUB_ENV + echo "GATEWAY_MAX_CONCURRENT_REQUESTS_PER_USER=$GATEWAY_MAX_CONCURRENT_REQUESTS_PER_USER" >> $GITHUB_ENV + - name: 'Print environment variables' # This is a useful record of what the environment variables were at the time the job ran, for debugging and reference run: |