Skip to content

Commit 7afd13e

Browse files
ci: add Cloudflare Pages deployment with noindex headers
1 parent 05c8be0 commit 7afd13e

File tree

4 files changed

+182
-1
lines changed

4 files changed

+182
-1
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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"

docs/cloudflare-deploy-runbook.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Cloudflare Pages Deploy (token-dashboard-legacy)
2+
3+
## Workflow
4+
5+
- File: `.github/workflows/cloudflare-legacy-deployment.yml`
6+
- Trigger: `workflow_dispatch` with inputs
7+
- `branch` (default `main`)
8+
- `env_prefix` (optional path/alias override)
9+
- Jobs: `Build` (yarn build, artifact upload) → `Deploy` (wrangler pages deploy)
10+
→ smoke check.
11+
- Environment gate: `cloudflare-production` (approve in Actions UI).
12+
13+
## Required secrets
14+
15+
- `CF_PAGES_API_TOKEN` (Pages:Edit scope)
16+
- `CLOUDFLARE_ACCOUNT_ID`
17+
- Build secrets: `ALCHEMY_API_KEY`, `MAINNET_ELECTRUMX_PROTOCOL`,
18+
`MAINNET_ELECTRUMX_HOST`, `MAINNET_ELECTRUMX_PORT`, `MAINNET_SENTRY_DSN`,
19+
`TRM_SUPPORT`, `WALLET_CONNECT_PROJECT_ID`, `TBTC_SUBGRAPH_API_KEY`,
20+
`GOOGLE_TAG_MANAGER_ID`, `GOOGLE_TAG_MANAGER_SUPPORT` (true/false in workflow
21+
env).
22+
23+
## How to deploy
24+
25+
```bash
26+
# from any machine with gh auth
27+
gh workflow run cloudflare-legacy-deployment.yml -f branch=main
28+
# approve the environment prompt in GitHub Actions
29+
```
30+
31+
- Production URL: https://token-dashboard-legacy.pages.dev
32+
- Custom domain: https://old-app.threshold.network
33+
- Post-deploy smoke: curls
34+
`https://old-app.threshold.network/overview/network` (fails the job on
35+
non-200/301).
36+
37+
## Notes
38+
39+
- Wrangler pinned to 4.50.0.
40+
- If you need a preview alias, pass `env_prefix=preview/<branch>` so Pages uses
41+
that alias.
42+
- Redirects/headers can be added via `_redirects` / `_headers` in the repo.
43+
- Current legacy deployment is intentionally non-indexable: `_headers` sets
44+
`X-Robots-Tag: noindex, nofollow` and `robots.txt` disallows all. Remove these
45+
when you want search indexing back.

public/_headers

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/*
2+
X-Robots-Tag: noindex, nofollow

public/robots.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# https://www.robotstxt.org/robotstxt.html
2+
# Block all crawlers for legacy Cloudflare deployment
23
User-agent: *
3-
Disallow:
4+
Disallow: /

0 commit comments

Comments
 (0)