-
Notifications
You must be signed in to change notification settings - Fork 662
90 lines (79 loc) · 3.97 KB
/
Copy pathui-refresh.yml
File metadata and controls
90 lines (79 loc) · 3.97 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
name: 🔄 Refresh UI token index
# The UI's token index (`_config/ui/public/data`) is committed so the Vercel build reads it
# instead of regenerating it — regeneration hit public RPCs + DefiLlama on every deploy and took
# ~16 min. This job regenerates the index (recency from git history, popularity from DefiLlama,
# metadata from on-chain) and commits it back, which triggers a normal, now-fast redeploy. It runs
# when a token/chain logo lands on main, plus weekly to refresh market caps.
on:
push:
branches:
- main
# Only real logo additions/removals — NOT the frequent bot `list.json`/`_info.json` churn,
# which does not change the generated index.
paths:
- 'tokens/**/logo.svg'
- 'chains/**/logo.svg'
schedule:
# Every Monday at 06:00 UTC — refresh popularity (market caps) even without token changes.
- cron: '0 6 * * 1'
workflow_dispatch:
permissions:
contents: write
concurrency:
group: ui-refresh
cancel-in-progress: true
jobs:
refresh:
runs-on: ubuntu-latest
steps:
- name: Checkout repo (full history for recency dates)
uses: actions/checkout@v4
with:
# addedAt is derived from git history; a shallow clone would collapse every date
# to the last commit. Credentials persist (default) so the index can be pushed back.
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install deps
working-directory: _config/ui
run: bun install --frozen-lockfile
- name: Record current token count
id: before
working-directory: _config/ui
run: |
COUNT=$(node -e 'try{process.stdout.write(String(require("./public/data/chains.json").totalTokens||0))}catch{process.stdout.write("0")}')
echo "count=$COUNT" >> "$GITHUB_OUTPUT"
- name: Regenerate token index (recency + market caps + on-chain metadata)
working-directory: _config/ui
run: bun run generate
- name: Guard against a broken regeneration
working-directory: _config/ui
# Pass the baseline through env, not inline ${{ }} interpolation, to keep untrusted-looking
# values out of the shell (GitHub Actions script-injection hardening).
env:
OLD: ${{ steps.before.outputs.count }}
run: |
NEW=$(node -e 'try{process.stdout.write(String(require("./public/data/chains.json").totalTokens||0))}catch{process.stdout.write("0")}')
echo "token count: old=$OLD new=$NEW"
if [ "$NEW" -lt 1000 ]; then
echo "::error::Regenerated index has only $NEW tokens; refusing to commit a broken index."
exit 1
fi
if [ "$OLD" -gt 0 ] && [ "$NEW" -lt $((OLD * 80 / 100)) ]; then
echo "::error::Token count collapsed ($OLD -> $NEW); refusing to commit."
exit 1
fi
- name: Commit the refreshed index (triggers a fast redeploy)
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add _config/ui/public/data
if git diff --cached --quiet; then
echo "Index unchanged; nothing to commit."
else
git commit -m "chore: refresh UI token index"
# main can advance during the multi-minute regeneration (bot list updates, merges);
# rebase our data commit on top before pushing so a concurrent push isn't rejected.
git pull --rebase origin main
git push origin HEAD:main
fi