forked from ping-pub/mainnet
-
Notifications
You must be signed in to change notification settings - Fork 2
134 lines (113 loc) · 4.14 KB
/
Copy pathdeploy.yaml
File metadata and controls
134 lines (113 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Deploy to GitHub Pages
on:
push:
branches: [ main ]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
name: Build site
runs-on: ubuntu-latest
steps:
- name: Git Checkout Latest
uses: actions/checkout@v7
with:
submodules: recursive
- name: Update explorer to latest
run: |
git submodule update --remote --checkout explorer
git -C explorer log -1 --oneline
- name: Disable CoinGecko on testnet
run: |
node <<'NODE'
const fs = require('fs');
const updateFile = (path, replacements) => {
let source = fs.readFileSync(path, 'utf8');
for (const [from, to] of replacements) {
if (!source.includes(from)) {
throw new Error(`Expected text not found in ${path}: ${from}`);
}
source = source.replace(from, to);
}
fs.writeFileSync(path, source);
};
updateFile('explorer/src/stores/useCoinGecko.ts', [
[
"const LocalStoreKey = 'currency';",
"const LocalStoreKey = 'currency';\nconst disableCoingecko = window.location.hostname.includes('testnet');",
],
[
"return get(`${coingeckoUrl}/api/v3/coins/${coinId}/market_chart?vs_currency=usd&days=${days}`);",
"return disableCoingecko\n ? Promise.resolve({ prices: [], market_caps: [], total_volumes: [] })\n : get(`${coingeckoUrl}/api/v3/coins/${coinId}/market_chart?vs_currency=usd&days=${days}`);",
],
[
"fetchCoinPrice(ids: string[]) {",
"fetchCoinPrice(ids: string[]) {\n if (disableCoingecko) return;",
],
[
"return get(`${coingeckoUrl}/api/v3/coins/${coinId}`);",
"return disableCoingecko ? Promise.resolve({ tickers: [] }) : get(`${coingeckoUrl}/api/v3/coins/${coinId}`);",
],
]);
updateFile('explorer/src/stores/useDashboard.ts', [
[
"loadingPrices() {",
"loadingPrices() {\n if (window.location.hostname.includes('testnet')) return;",
],
]);
updateFile('explorer/src/modules/wallet/portfolio.vue', [
[
"function loadPrice() {",
"function loadPrice() {\n if (window.location.hostname.includes('testnet')) return;",
],
]);
NODE
grep -n "disableCoingecko\|loadingPrices\|function loadPrice" explorer/src/stores/useCoinGecko.ts explorer/src/stores/useDashboard.ts explorer/src/modules/wallet/portfolio.vue
- name: Setup Pages
uses: actions/configure-pages@v6
- name: Setup Node.js
uses: actions/setup-node@v6.4.0
with:
node-version: 22
cache: yarn
cache-dependency-path: explorer/yarn.lock
- name: Setup testnet config
run: |
mkdir -p explorer/chains/testnet
rm -f explorer/chains/mainnet/*.json explorer/chains/testnet/*.json
cp chains/testnet/*.json explorer/chains/testnet/
- name: Install dependencies
working-directory: explorer
run: yarn install --frozen-lockfile
- name: Build
working-directory: explorer
run: yarn build
env:
NODE_OPTIONS: --max_old_space_size=4096
- name: Copy logos
run: cp -rf logos explorer/dist/
- name: Set custom domain
run: echo testnet.ping.pub > explorer/dist/CNAME
- name: Create SPA 404 fallback
run: cp explorer/dist/index.html explorer/dist/404.html
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v5
with:
path: explorer/dist
deploy:
name: Deploy site
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5