-
Notifications
You must be signed in to change notification settings - Fork 1
134 lines (123 loc) · 4.72 KB
/
cron.arbitrum-sepolia.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
name: CronJob - Arbitrum Sepolia
on:
schedule:
- cron: "*/90 * * * *" # ie. 4:00pm, 5:30pm, 7:00pm, etc.
push:
env:
CHAIN_ID: 421614
PRIZE_POOL_ADDRESS: "0xdBBC646D78Ca1752F2DB6EA76DC467F740f9f816"
VAULT_ACCOUNTS_DIRECTORY_NAME: "vaultAccounts"
OUTPUT_DIRECTORY_NAME: "winners"
CLI_VERSION: "1.1.7"
FWC_RPC_URL: ${{ secrets.ARBITRUM_SEPOLIA_RPC_URL }}
JSON_RPC_URL: ${{ secrets.ARBITRUM_SEPOLIA_RPC_URL }}
NODE_OPTIONS: "--max_old_space_size=32768"
permissions: write-all
jobs:
runCLI:
name: Winners Compute
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 1
matrix:
node: ["20.11.1"]
os: [ubuntu-latest]
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: recursive
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Clone foundry-winner-calc repo
uses: actions/checkout@master
with:
repository: GenerationSoftware/foundry-winner-calc
path: './foundry-winner-calc'
# -------------------------------------------------------- #
# Arbitrum Sepolia
# -------------------------------------------------------- #
# 1. Install
- name: Install PoolTogether V5 CLI
run: |
npm install -g @generationsoftware/pt-v5-cli@${{ env.CLI_VERSION }}
echo "$(npm -g bin)" >> $GITHUB_PATH
# 2. Compute JSON input files (vault accounts)
- name: Arbitrum Sepolia Vault Accounts
id: vaultAccountsArbitrumSepolia
uses: chuckbergeron/executable-wrapper@f94b435740d6b958c2d7eb76c77657e761819cfe
continue-on-error: true
with:
working-directory: ./foundry-winner-calc
run_command: ptv5 utils vaultAccounts -o ./${{ env.VAULT_ACCOUNTS_DIRECTORY_NAME }} -p ${{ env.PRIZE_POOL_ADDRESS }} -c ${{ env.CHAIN_ID }}
# 3. Install package deps, build contracts
- name: Install deps and compile
run: |
cd ./foundry-winner-calc
npm install
npm run build
cd sol
forge install
forge build
cd ..
# 4. Store list of input JSON files in variable
- name: Finding files
working-directory: ./foundry-winner-calc
run: |
{
echo 'FILELIST<<EOF'
find ./${{ env.VAULT_ACCOUNTS_DIRECTORY_NAME }} -type f -name '0x*.json' -print
echo EOF
} >> "$GITHUB_ENV"
# 5. Loop through vault input files, compute winners
- name: Iterate vaults
id: processVaults
working-directory: ./foundry-winner-calc
run: |
for i in $FILELIST; do
echo "Processing: ${i}"
node index.js ${i} ../${{ env.OUTPUT_DIRECTORY_NAME }}/${i}
done
# 6. Concat winner output files into 1 winners.json file
- name: Concat Winner Files
uses: chuckbergeron/executable-wrapper@f94b435740d6b958c2d7eb76c77657e761819cfe
continue-on-error: true
with:
working-directory: ./${{ env.OUTPUT_DIRECTORY_NAME }}
run_command: ptv5 utils concatWinners -o ./${{ env.VAULT_ACCOUNTS_DIRECTORY_NAME }} -p ${{ env.PRIZE_POOL_ADDRESS }} -c ${{ env.CHAIN_ID }}
# 7. Commit
- name: Commit Arbitrum Sepolia
if: steps.vaultAccountsArbitrumSepolia.outputs.runStatus == 'true'
continue-on-error: true
run: |
git config pull.rebase false
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git pull
git add ./${{ env.OUTPUT_DIRECTORY_NAME }}
git commit -m "Add testnet winner results for Arbitrum Sepolia draw #${{ steps.vaultAccountsArbitrumSepolia.outputs.drawId }}"
# 8. Push
- name: Push changes (if required)
uses: ad-m/github-push-action@master
if: steps.vaultAccountsArbitrumSepolia.outputs.runStatus == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
force: true
# Optionally:
- name: Comment Error
id: commentError
if: steps.vaultAccountsArbitrumSepolia.outputs.exitcode == 1
uses: actions/github-script@v5
continue-on-error: true
with:
script: |
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Draw #${{ steps.vaultAccountsArbitrumSepolia.outputs.drawId }} Winner Calc Failed: Exit Code 1`
})