|
| 1 | +name: Cloudflare Pages Deploy (production) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + branch: |
| 7 | + description: "Git ref/branch to deploy" |
| 8 | + required: false |
| 9 | + default: "main" |
| 10 | + env_prefix: |
| 11 | + description: "Optional path prefix (e.g., preview/<branch>)" |
| 12 | + required: false |
| 13 | + default: "" |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + name: Build |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + env: |
| 22 | + NODE_VERSION: "20" |
| 23 | + PUBLIC_URL: / |
| 24 | + CANONICAL_HOSTNAME: old-app.threshold.network |
| 25 | + CHAIN_ID: 1 |
| 26 | + ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} |
| 27 | + ELECTRUM_PROTOCOL: ${{ secrets.MAINNET_ELECTRUMX_PROTOCOL }} |
| 28 | + ELECTRUM_HOST: ${{ secrets.MAINNET_ELECTRUMX_HOST }} |
| 29 | + ELECTRUM_PORT: ${{ secrets.MAINNET_ELECTRUMX_PORT }} |
| 30 | + SENTRY_DSN: ${{ secrets.MAINNET_SENTRY_DSN }} |
| 31 | + TRM_SUPPORT: ${{ secrets.TRM_SUPPORT }} |
| 32 | + WALLET_CONNECT_PROJECT_ID: ${{ secrets.WALLET_CONNECT_PROJECT_ID }} |
| 33 | + TBTC_SUBGRAPH_API_KEY: ${{ secrets.TBTC_SUBGRAPH_API_KEY }} |
| 34 | + GOOGLE_TAG_MANAGER_ID: ${{ secrets.GOOGLE_TAG_MANAGER_ID }} |
| 35 | + GOOGLE_TAG_MANAGER_SUPPORT: true |
| 36 | + steps: |
| 37 | + - name: Checkout |
| 38 | + uses: actions/checkout@v4 |
| 39 | + with: |
| 40 | + ref: ${{ github.event.inputs.branch || 'main' }} |
| 41 | + |
| 42 | + - uses: actions/setup-node@v3 |
| 43 | + with: |
| 44 | + node-version: "20" |
| 45 | + cache: yarn |
| 46 | + |
| 47 | + - name: Force git to use https |
| 48 | + run: git config --global url."https://".insteadOf git:// |
| 49 | + |
| 50 | + - name: Install dependencies |
| 51 | + run: yarn install --ignore-scripts --frozen-lockfile |
| 52 | + |
| 53 | + - name: Postinstall |
| 54 | + run: yarn run postinstall |
| 55 | + |
| 56 | + - name: Build |
| 57 | + run: | |
| 58 | + PUBLIC_URL=${PUBLIC_URL} \ |
| 59 | + CANONICAL_HOSTNAME=${CANONICAL_HOSTNAME} \ |
| 60 | + CHAIN_ID=${CHAIN_ID} \ |
| 61 | + ALCHEMY_API_KEY=${ALCHEMY_API_KEY} \ |
| 62 | + ELECTRUM_PROTOCOL=${ELECTRUM_PROTOCOL} \ |
| 63 | + ELECTRUM_HOST=${ELECTRUM_HOST} \ |
| 64 | + ELECTRUM_PORT=${ELECTRUM_PORT} \ |
| 65 | + SENTRY_DSN=${SENTRY_DSN} \ |
| 66 | + TRM_SUPPORT=${TRM_SUPPORT} \ |
| 67 | + WALLET_CONNECT_PROJECT_ID=${WALLET_CONNECT_PROJECT_ID} \ |
| 68 | + TBTC_SUBGRAPH_API_KEY=${TBTC_SUBGRAPH_API_KEY} \ |
| 69 | + GOOGLE_TAG_MANAGER_SUPPORT=${GOOGLE_TAG_MANAGER_SUPPORT} \ |
| 70 | + GOOGLE_TAG_MANAGER_ID=${GOOGLE_TAG_MANAGER_ID} \ |
| 71 | + yarn build |
| 72 | +
|
| 73 | + - uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: build |
| 76 | + path: build |
| 77 | + |
| 78 | + deploy: |
| 79 | + name: Deploy to Cloudflare Pages |
| 80 | + needs: build |
| 81 | + runs-on: ubuntu-latest |
| 82 | + environment: |
| 83 | + name: cloudflare-production |
| 84 | + url: https://token-dashboard-legacy.pages.dev |
| 85 | + permissions: |
| 86 | + contents: read |
| 87 | + env: |
| 88 | + CF_PAGES_PROJECT: token-dashboard-legacy |
| 89 | + CLOUDFLARE_API_TOKEN: ${{ secrets.CF_PAGES_API_TOKEN }} |
| 90 | + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID || secrets.CF_ACCOUNT_ID }} |
| 91 | + steps: |
| 92 | + - name: Checkout |
| 93 | + uses: actions/checkout@v4 |
| 94 | + with: |
| 95 | + ref: ${{ github.event.inputs.branch || 'main' }} |
| 96 | + |
| 97 | + - uses: actions/download-artifact@v4 |
| 98 | + with: |
| 99 | + name: build |
| 100 | + path: build |
| 101 | + |
| 102 | + - name: Install wrangler |
| 103 | + run: npm install -g [email protected] |
| 104 | + |
| 105 | + - name: Deploy |
| 106 | + env: |
| 107 | + CF_DEPLOY_BRANCH: ${{ github.event.inputs.branch || 'main' }} |
| 108 | + CF_DEPLOY_ENV_PREFIX: ${{ github.event.inputs.env_prefix }} |
| 109 | + run: | |
| 110 | + set -euo pipefail |
| 111 | + export CLOUDFLARE_API_TOKEN |
| 112 | + export CF_API_TOKEN="$CLOUDFLARE_API_TOKEN" |
| 113 | + export CLOUDFLARE_ACCOUNT_ID |
| 114 | + if [ -z "$CLOUDFLARE_ACCOUNT_ID" ]; then |
| 115 | + echo "CLOUDFLARE_ACCOUNT_ID missing" >&2 |
| 116 | + exit 1 |
| 117 | + fi |
| 118 | + if [ -z "$CF_DEPLOY_ENV_PREFIX" ]; then |
| 119 | + BRANCH_NAME="$CF_DEPLOY_BRANCH" |
| 120 | + else |
| 121 | + BRANCH_NAME="$CF_DEPLOY_ENV_PREFIX" |
| 122 | + fi |
| 123 | + wrangler pages deploy build \ |
| 124 | + --project-name ${CF_PAGES_PROJECT} \ |
| 125 | + --branch ${BRANCH_NAME} |
| 126 | +
|
| 127 | + - name: Smoke check (post-deploy) |
| 128 | + env: |
| 129 | + SMOKE_URL: https://old-app.threshold.network/overview/network |
| 130 | + run: | |
| 131 | + set -euo pipefail |
| 132 | + echo "Smoke checking ${SMOKE_URL}" |
| 133 | + curl -I --fail "$SMOKE_URL" |
0 commit comments