forked from invariant-labs/leaderboard
-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (127 loc) · 4.67 KB
/
snap.yml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: "Create snapshot of points"
on:
# schedule:
# - cron: "*/5 * * * *" # every 5 minutes
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
env:
solana_version: 1.18.18
jobs:
points-snap:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
lfs: true
fetch-depth: 0
- name: Check Initial LFS Storage
run: |
git lfs install
echo "Initial LFS storage usage (mainnet files only):"
git lfs ls-files -l | grep "_mainnet.json" | awk '{total += $4} END {print total/1024/1024 " MB"}'
- uses: actions/setup-node@v2
with:
node-version: "16"
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: install global mocha
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
npm install -g mocha
npm install -g ts-mocha
npm install -g typescript
npm install -g @project-serum/anchor
ts-mocha -h
- name: install essential
run: |
sudo apt-get update
sudo apt-get install -y pkg-config build-essential libudev-dev
- name: install solana
run: |
sh -c "$(curl -sSfL https://release.anza.xyz/v${{ env.solana_version }}/install)"
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
solana --version
- name: setup solana
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
solana --version
solana-keygen new -o "$HOME/.config/solana/id.json" --no-passphrase --silent
- name: snapshot
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
export ANCHOR_WALLET="/home/runner/.config/solana/id.json"
npm install
npm run snap
- uses: actions/upload-artifact@v4
with:
name: eclipse-points-snapshot-${{ github.run_id }}
path: |
./data/*.json
deploy:
needs: [points-snap]
if: ${{ always() }}
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v2
with:
lfs: true
fetch-depth: 0
- name: Configure Git LFS
run: |
git lfs install
git lfs pull
# Configure LFS to track only mainnet files
git lfs track "data/*_mainnet.json"
echo "Current LFS storage before deployment (mainnet files only):"
git lfs ls-files -l | grep "_mainnet.json" | awk '{total += $4} END {print total/1024/1024 " MB"}'
- name: Download snapshot
uses: actions/download-artifact@v4
with:
name: eclipse-points-snapshot-${{ github.run_id }}
path: ./data/
continue-on-error: true
- name: Clean old mainnet snapshots
run: |
# Remove all mainnet JSON files except the most recent ones
cd ./data
for prefix in $(ls *_mainnet.json | sed 's/_mainnet.json//' | sort -u); do
ls -t ${prefix}_mainnet.json | tail -n +2 | xargs rm -f
done
cd ..
- name: Commit and Push Changes
run: |
git config --global user.email [email protected]
git config --global user.name invariantStats
# Ensure only mainnet files are tracked by LFS
git lfs track "data/*_mainnet.json"
git add .gitattributes
# Add all files (LFS will handle mainnet files automatically)
git add ./data/
git commit -m "Snapshot of points done!"
# Push LFS objects first
git lfs push origin master --all
# Then push the regular files
git push origin master --force
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check Final LFS Storage
run: |
echo "Final LFS storage usage after deployment (mainnet files only):"
git lfs ls-files -l | grep "_mainnet.json" | awk '{total += $4} END {print total/1024/1024 " MB"}'
- uses: actions/setup-node@v2
with:
node-version: "16"
- name: Deploy to Production
uses: amondnet/vercel-action@v20
id: deploy-vercel-production
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
vercel-args: "--prod"
scope: ${{ secrets.VERCEL_ORG_ID }}