Skip to content

Merge pull request #766 from threshold-network/rewards-jul-1-2024 #210

Merge pull request #766 from threshold-network/rewards-jul-1-2024

Merge pull request #766 from threshold-network/rewards-jul-1-2024 #210

name: Token Dashboard / Mainnet
on:
push:
branches:
- releases/mainnet/**
release:
types:
- "published"
jobs:
build:
name: Build for mainnet
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18"
cache: "yarn"
# This step forces Git to download dependencies using `https://` protocol,
# even if `yarn.json` refers to some package via `git://`. Using `git://`
# is no longer supported by GH. One of the dashboard dependencies by
# default uses `git://` and we needed to manually remove it every time
# it re-appeared in the lock file. Now even if it does re-appear, the
# `yarn install --frozen-lockfile` will not fail.
- name: Configure git to don't use unauthenticated protocol
run: git config --global url."https://".insteadOf git://
- name: Install dependencies
run: yarn install --ignore-scripts --frozen-lockfile
- name: Run token-dashboard post-install script
run: yarn run postinstall
# FIXME: It's work in progress, the contracts are not yet published.
# - name: Resolve latest mainnet contracts
# # For PR we expect the dependencies are already set to correct versions.
# if: github.event_name != 'pull_request'
# run: |
# yarn upgrade \
# @threshold-network/contracts@mainnet
- name: Build
if: github.event_name == 'push'
run: yarn build
env:
PUBLIC_URL: /${{ github.ref_name }}
CHAIN_ID: 1
ETH_HOSTNAME_HTTP: ${{ secrets.MAINNET_ETH_HOSTNAME_HTTP }}
ETH_HOSTNAME_WS: ${{ secrets.MAINNET_ETH_HOSTNAME_WS }}
NODE_OPTIONS: --max_old_space_size=4096
ELECTRUM_PROTOCOL: ${{ secrets.MAINNET_ELECTRUMX_PROTOCOL }}
ELECTRUM_HOST: ${{ secrets.MAINNET_ELECTRUMX_HOST }}
ELECTRUM_PORT: ${{ secrets.MAINNET_ELECTRUMX_PORT }}
SENTRY_SUPPORT: true
SENTRY_DSN: ${{ secrets.MAINNET_SENTRY_DSN }}
TRM_API_KEY: ${{ secrets.TEST_TRM_API_KEY }}
TRM_SUPPORT: ${{ secrets.TRM_SUPPORT }}
WALLET_CONNECT_PROJECT_ID: ${{ secrets.WALLET_CONNECT_PROJECT_ID }}
GOOGLE_TAG_MANAGER_SUPPORT: false
GOOGLE_TAG_MANAGER_ID: ${{ secrets.GOOGLE_TAG_MANAGER_ID }}
- name: Build
if: github.event_name == 'release'
run: yarn build
env:
PUBLIC_URL: /
CHAIN_ID: 1
ETH_HOSTNAME_HTTP: ${{ secrets.MAINNET_ETH_HOSTNAME_HTTP }}
ETH_HOSTNAME_WS: ${{ secrets.MAINNET_ETH_HOSTNAME_WS }}
NODE_OPTIONS: --max_old_space_size=4096
POSTHOG_SUPPORT: true
POSTHOG_API_KEY: ${{ secrets.MAINNET_POSTHOG_API_KEY }}
POSTHOG_HOSTNAME_HTTP: ${{ secrets.MAINNET_POSTHOG_HOSTNAME_HTTP }}
ELECTRUM_PROTOCOL: ${{ secrets.MAINNET_ELECTRUMX_PROTOCOL }}
ELECTRUM_HOST: ${{ secrets.MAINNET_ELECTRUMX_HOST }}
ELECTRUM_PORT: ${{ secrets.MAINNET_ELECTRUMX_PORT }}
SENTRY_SUPPORT: true
SENTRY_DSN: ${{ secrets.MAINNET_SENTRY_DSN }}
TRM_API_KEY: ${{ secrets.MAINNET_TRM_API_KEY }}
TRM_SUPPORT: ${{ secrets.TRM_SUPPORT }}
WALLET_CONNECT_PROJECT_ID: ${{ secrets.WALLET_CONNECT_PROJECT_ID }}
GOOGLE_TAG_MANAGER_SUPPORT: true
GOOGLE_TAG_MANAGER_ID: ${{ secrets.GOOGLE_TAG_MANAGER_ID }}
- uses: actions/upload-artifact@v3
with:
name: build
path: build
deploy-preview:
name: Deploy mainnet preview
needs: build
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- name: Deploy PR mainnet preview to GCP
# Temporarily we run the action in version from `alpine-version-413.0.0`
# branch, which contains a fix for the issue introduced in the `414.0.0`
# version of the `cloud-sdk` (`rsync` fails for users with no
# `storage.buckets.get` permission).
uses: thesis/gcp-storage-bucket-action@alpine-version-413.0.0
with:
service-key: ${{ secrets.MAINNET_PREVIEW_UPLOADER_SERVICE_KEY_JSON_BASE64 }}
project: ${{ secrets.MAINNET_PREVIEW_GOOGLE_PROJECT_ID }}
bucket-name: preview.dashboard.threshold.network
bucket-path: ${{ github.ref_name }}
build-folder: build
deploy:
name: Deploy mainnet
needs: build
if: github.event_name == 'release'
# mainnet environment is protected, it requires an approval before execution.
environment:
name: mainnet
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- name: Deploy mainnet build to GCP
# Temporarily we run the action in version from `alpine-version-413.0.0`
# branch, which contains a fix for the issue introduced in the `414.0.0`
# version of the `cloud-sdk` (`rsync` fails for users with no
# `storage.buckets.get` permission).
uses: thesis/gcp-storage-bucket-action@alpine-version-413.0.0
with:
service-key: ${{ secrets.MAINNET_UPLOADER_SERVICE_KEY_JSON_BASE64 }}
project: ${{ secrets.MAINNET_GOOGLE_PROJECT_ID }}
bucket-name: dashboard.threshold.network
build-folder: build
set-website: true
home-page-path: index.html
error-page-path: index.html